0% found this document useful (0 votes)
13 views

Assessment_1_-_Computational_Thinking_-_AK (3)

The document covers fundamental programming concepts including variables, constants, operators, and objects, as well as the differences between compilers and interpreters. It discusses abstraction in computer science with examples, outlines pseudocode tracing, and defines pre-conditions and post-conditions. Additionally, it presents a case study on a library management system, detailing procedures, decision-making conditions, and the advantages and challenges of concurrent processing.

Uploaded by

failsaveacc35
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Assessment_1_-_Computational_Thinking_-_AK (3)

The document covers fundamental programming concepts including variables, constants, operators, and objects, as well as the differences between compilers and interpreters. It discusses abstraction in computer science with examples, outlines pseudocode tracing, and defines pre-conditions and post-conditions. Additionally, it presents a case study on a library management system, detailing procedures, decision-making conditions, and the advantages and challenges of concurrent processing.

Uploaded by

failsaveacc35
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Section A: Short Answer Questions

1. Define the following terms: (4 marks)


a) Variable: A storage location for data in a program that can be changed during execution.
b) Constant: An identifier with an associated value that cannot be altered during program
execution.
c) Operator: A symbol or set of symbols that represents an action or operation to be performed
on one or more operands.
d) Object: In object-oriented programming, an instance of a class that contains both data
(attributes) and methods (behaviors).

2. Explain the difference between a compiler and an interpreter. (4 marks)


A compiler translates the entire source code into machine code in a single process before
execution. The resulting executable file can be run multiple times without recompilation. An
interpreter, on the other hand, translates and executes the source code line by line during runtime.
Compiled programs generally run faster, while interpreted languages offer more flexibility and
easier debugging.

3. Explain the concept of abstraction and provide an example of abstraction in computer


science. (4 marks)
Abstraction is the process of simplifying complex systems by focusing on essential features
while hiding unnecessary details. It helps manage complexity in computer systems. An example of
abstraction in computer science is the use of high-level programming languages, which abstract
away the complexities of machine code, allowing programmers to write code in a more human-
readable format.

Section B: Extended Response Questions

4. (Tracing and analysis of given pseudocode)


a) Tracing: (6 marks)
After iteration 3: SUM = 85, COUNT = 1
After iteration 6: SUM = 175, COUNT = 2
After iteration 8: SUM = 240, COUNT = 3
After iteration 10: SUM = 300, COUNT = 4

b) Purpose: (2 marks)
The algorithm calculates the average of numbers greater than 50 in the given array.

c) Example of abstraction: (2 marks)


The use of a loop to iterate through the array is an abstraction, hiding the complexity of
accessing each element individually.

d) Suggestion for efficiency: (3 marks)


The loop could be changed to exit early once it reaches the end of the array, rather than
always iterating 10 times:
loop I from 0 to length (NUMS) - 1
5. a) Define pre-condition and post-condition: (4 marks)
Pre-condition: A condition or set of conditions that must be true before a function or algorithm is
executed.
Post-condition: A condition or set of conditions that must be true after a function or algorithm
has completed execution.

b) For square root function:


i) Pre-condition: (1 mark)
The input number must be non-negative (>= 0).

ii) Post-condition: (1 mark)


The square of the output value must be displayed on the screen.

Section C: Case Study

6. Library management system

a) Four main procedures: (2 marks)


- borrowBook ()
- returnBook ()
- searchBooks ()
- addNewBook ()

b) Two decisions and conditions: (2 marks)


1. Decision: Whether a student can borrow a book
Condition: The student has fewer than the maximum allowed borrowed books
2. Decision: Whether a book is overdue
Condition: The current date is after the book's due date

c) Concurrent processing in library system: (5 marks)


Concurrent processing could be used to handle multiple user requests simultaneously, such as
allowing multiple students to search for books or borrow books at the same time. This would be
beneficial in a busy library where many users interact with the system concurrently.

Advantages:
- Improved responsiveness for users
- Better utilization of system resources
- Ability to handle more users simultaneously

Challenges:
- Need to implement proper synchronization to prevent issues like two students trying to borrow
the same book simultaneously
- Increased complexity in system design and implementation
- Potential for race conditions or deadlocks if not carefully managed

Overall, implementing concurrent processing would likely be beneficial for a library system,
especially in larger libraries with many users, as it would improve the system's efficiency and user
experience. However, careful design and testing would be necessary to ensure data integrity and
system stability.

You might also like