← Back to quizzesFree quiz

Fundamentals of Computing and Programming

Cloud computing offers several service models, each providing a different level of control to the user. The three primary models are Infrastructure as a Service (IaaS) , Platform as a…

11 questions~6 min
Fundamentals of Computing and Programming — Qwi
0 / 11
Score: 0%
1

Which layer of cloud computing provides the most control to the user over software functionality?

2

When compiling a high‑level language program, which of the following statements is true about the generated object code?

3

In C++, what is the difference between the expressions `x = y++;` and `x = ++y;` assuming `x` and `y` are integers?

4

Which of the following best describes a situation where a selection statement (if‑else) is more appropriate than a loop?

5

Consider an array declared as `int a[10];`. Which of the following statements about its indexing is correct in C++?

6

In a typical Unix file system, what is the purpose of a symbolic link?

7

Which sorting algorithm is guaranteed to be stable and runs in O(n log n) time on average?

8

In a decision table, what distinguishes a contracted table from an expanded table?

9

When comparing procedural programming to object‑oriented programming, which statement best captures a key advantage of OOP?

10

Which of the following best explains why a data flow diagram (DFD) does not show the timing or sequencing of processes?

11

In the context of file systems, what is the main benefit of using a block size that matches the typical size of files?

Understanding Cloud Service Models

Cloud computing offers several service models, each providing a different level of control to the user. The three primary models are Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS). Among these, Platform as a Service (PaaS) gives developers the most control over software functionality while abstracting away the underlying hardware.

  • IaaS: Provides virtualized hardware resources (CPU, memory, storage). Users manage operating systems, middleware, and applications.
  • PaaS: Supplies a development platform (runtime, databases, middleware). Users focus on writing and deploying code, controlling the software stack but not the hardware.
  • SaaS: Delivers complete applications over the internet. Users have minimal control, limited to configuration settings.

Choosing the right model depends on the balance between flexibility and management overhead. For projects that require custom business logic, APIs, or unique runtime environments, PaaS is the optimal choice.

The Compilation Process Explained

When a high‑level language program is compiled, the process typically involves several distinct stages:

  1. Preprocessing: Handles directives such as #include and macro expansion.
  2. Compilation: Translates source code into intermediate object code (machine‑level instructions) but does not yet resolve external references.
  3. Assembly: Converts object code into binary machine code.
  4. Linking: Combines multiple object files and libraries into a final executable.

The object code is generated before the final executable, which means the compilation step is not the slowest part of the pipeline; linking can add additional time, especially for large projects with many dependencies.

Understanding this workflow helps developers diagnose build‑time errors and optimize build systems using techniques like incremental compilation.

Post‑Increment vs. Pre‑Increment in C++

In C++, the expressions x = y++; and x = ++y; appear similar but behave differently because of the order in which the increment operation occurs relative to the assignment.

  • Post‑increment (y++): Returns the original value of y and then increments y. Consequently, x receives the original value, while y becomes y+1 after the statement.
  • Pre‑increment (++y): Increments y first, then returns the new value. Thus, both x and y receive the incremented value.

Example:

int x, y = 5;
// Post‑increment
x = y++; // x = 5, y = 6
// Reset y
y = 5;
// Pre‑increment
x = ++y; // x = 6, y = 6

Choosing the correct form is crucial for avoiding off‑by‑one errors in loops and algorithms.

When to Use Selection Statements Instead of Loops

A selection statement (such as if‑else) is ideal when a program must decide between two mutually exclusive actions based on a single condition. Unlike loops, which repeat actions, selection statements execute only one branch of code.

  • Use if‑else when you need to choose between two paths, e.g., validating user input or determining a mode of operation.
  • Use loops (for, while) when you need to repeat an operation until a condition changes, such as iterating over an array or processing a stream of data.

Understanding the distinction helps write clearer, more efficient code and reduces unnecessary complexity.

Array Indexing in C++

Arrays in C++ are zero‑based, meaning the first element is accessed with index 0. For an array declared as int a[10];:

  • First element: a[0]
  • Last element: a[9] (since indices run from 0 to size‑1)
  • Accessing a[10] is out‑of‑bounds and leads to undefined behavior.

Attempting to use negative indices does not automatically wrap around to the end of the array; C++ does not provide built‑in bounds checking, so such mistakes can cause crashes or security vulnerabilities.

Symbolic Links in Unix File Systems

A symbolic link (or symlink) is a special type of file that contains a reference to another pathname. It acts like a shortcut, allowing multiple directory entries to point to the same target without duplicating the file’s data.

  • Creates a lightweight reference, saving storage space.
  • Can link across file systems, unlike hard links which are limited to the same filesystem.
  • When the target file is moved or deleted, the symlink becomes dangling (broken).

Symlinks are widely used for versioned libraries, configuration management, and simplifying complex directory structures.

Stable Sorting Algorithms: Merge Sort

Sorting is a fundamental operation in computer science. A stable sort preserves the relative order of records with equal keys. Merge sort satisfies two important criteria:

  • It runs in O(n log n) time on average and in the worst case.
  • It is stable because it merges sub‑arrays while maintaining the original order of equal elements.

Merge sort works by recursively dividing the array into halves, sorting each half, and then merging the sorted halves. Although it requires additional memory for the temporary arrays, its predictable performance and stability make it ideal for sorting linked lists and large datasets where order preservation matters.

Decision Tables: Contracted vs. Expanded Forms

Decision tables are a concise way to represent complex business rules. Two common formats are expanded and contracted tables.

  • Expanded table: Lists every possible combination of conditions, often resulting in many rows, some of which may be redundant.
  • Contracted table: Merges rows that lead to identical actions, eliminating redundancy and making the table more compact.

By contracting a decision table, analysts reduce maintenance effort and improve readability while preserving logical completeness.

Key Takeaways

Mastering the concepts covered in this course equips you with a solid foundation for both theoretical and practical aspects of computing:

  • Choose the appropriate cloud service model—PaaS for maximum software control.
  • Understand each compilation stage; object code precedes the final executable.
  • Distinguish between post‑increment and pre‑increment operators in C++.
  • Apply selection statements for mutually exclusive decisions, reserving loops for repetition.
  • Remember that C++ arrays are zero‑based; out‑of‑bounds access leads to undefined behavior.
  • Use symbolic links to create flexible, space‑efficient references in Unix.
  • Prefer merge sort when stability and guaranteed O(n log n) performance are required.
  • Contract decision tables to eliminate redundancy and simplify rule management.

These principles are essential for writing efficient, maintainable code and for designing robust software systems.