17-COMP-A4 Program Design and Data Structures Exam A, Exams of Technology

Exam A introduces basic programming concepts and fundamental data structures such as arrays, linked lists, stacks, and queues. Candidates learn algorithm design, complexity analysis, and implementation techniques essential for software development and problem solving.

Typology: Exams

2024/2025

Available from 06/04/2025

nicky-jone
nicky-jone 🇮🇳

2.9

(44)

28K documents

1 / 126

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
17-COMP-A4 Program Design and
Data Structures Exam A
Question 1. Which of the following best describes a variable in
programming?
A) A fixed value that cannot change during execution
B) A reserved keyword in the programming language
C) A storage location identified by a name that can hold data
D) A function that returns a value
Answer: C
Explanation: A variable is a named storage location in memory that can hold
data which can be changed during program execution.
Question 2. Which data type is most appropriate for storing whole numbers
in a typical programming language?
A) float
B) string
C) int
D) boolean
Answer: C
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download 17-COMP-A4 Program Design and Data Structures Exam A and more Exams Technology in PDF only on Docsity!

Data Structures Exam A

Question 1. Which of the following best describes a variable in programming? A) A fixed value that cannot change during execution B) A reserved keyword in the programming language C) A storage location identified by a name that can hold data D) A function that returns a value Answer: C Explanation: A variable is a named storage location in memory that can hold data which can be changed during program execution. Question 2. Which data type is most appropriate for storing whole numbers in a typical programming language? A) float B) string C) int D) boolean Answer: C

Data Structures Exam A

Explanation: The 'int' data type is used to store integer (whole number) values. Question 3. Which operator is used for logical AND in most programming languages? A) & B) && C) | D) || Answer: B Explanation: '&&' is the logical AND operator, which evaluates to true if both operands are true. Question 4. What is the primary purpose of the 'if' statement? A) To execute a block of code repeatedly B) To select one block of code to execute based on a condition C) To define a function D) To declare a variable Answer: B

Data Structures Exam A

Explanation: Passing by reference allows the function to modify the original variable because it operates on its memory address. Question 7. Which recursive function is commonly used to compute factorial? A) factorial(n) = n + factorial(n-1) B) factorial(n) = 1 if n=0, else n * factorial(n-1) C) factorial(n) = factorial(n-1) / n D) factorial(n) = n^2 + factorial(n-1) Answer: B Explanation: The recursive factorial function multiplies n by the factorial of n- 1, with 0! defined as 1, which is the base case. Question 8. Which principle states that program flow should follow a clear, logical sequence? A) Modular programming B) Structured programming C) Object-oriented programming D) Event-driven programming

Data Structures Exam A

Answer: B Explanation: Structured programming emphasizes using sequence, selection, and iteration to make code clear and logical. Question 9. Which of the following is a benefit of modular programming? A) Increased code duplication B) Reduced code readability C) Reusability of code blocks D) Difficulty in debugging Answer: C Explanation: Modular programming promotes reusability, maintainability, and easier debugging by breaking down complex problems into smaller modules. Question 10. Which core OOP concept involves hiding complex implementation details? A) Encapsulation B) Inheritance C) Polymorphism

Data Structures Exam A

D) Flexibility through polymorphism Answer: C Explanation: Increased coupling is generally a negative aspect; OOP aims to reduce coupling to improve modularity. Question 13. Which phase involves understanding the problem and defining requirements before coding? A) Implementation phase B) Testing phase C) Problem analysis D) Deployment phase Answer: C Explanation: Problem analysis involves understanding requirements and planning before implementation. Question 14. Which diagram is useful for representing the flow of control in an algorithm? A) Data flow diagram B) Entity-relationship diagram

Data Structures Exam A

C) Flowchart D) Class diagram Answer: C Explanation: Flowcharts visually depict the sequence of operations in an algorithm, illustrating control flow. Question 15. Which coding convention improves code readability? A) Using meaningful variable names B) Omitting comments C) Writing all code in a single line D) Avoiding indentation Answer: A Explanation: Using meaningful variable names enhances understandability, making code easier to read and maintain. Question 16. Which debugging technique involves systematically checking code to locate errors? A) Rubber duck debugging B) Breakpoint debugging

Data Structures Exam A

B) Omega (Ω) C) Theta (Θ) D) Delta (Δ) Answer: A Explanation: Big O notation describes the upper bound or worst-case time complexity of an algorithm. Question 19. Which data type is most suitable for storing a sequence of characters? A) int B) float C) string D) boolean Answer: C Explanation: Strings are sequences of characters used for text data. Question 20. Which operation is NOT typically associated with arrays? A) Traversal B) Insertion at arbitrary position with shifting

Data Structures Exam A

C) Dynamic resizing without reallocation D) Binary search on sorted array Answer: C Explanation: Arrays have a fixed size; dynamic resizing requires creating a new array and copying data. Question 21. Which string operation compares two strings for equality? A) copy() B) concatenate() C) strcmp() D) length() Answer: C Explanation: 'strcmp()' compares two strings lexicographically, returning 0 if they are equal. Question 22. What is the main characteristic of a stack? A) FIFO (First-In, First-Out) B) LIFO (Last-In, First-Out) C) Random access

Data Structures Exam A

D) Linked list Answer: B Explanation: A stack supports last-in, first-out operations ideal for backtracking algorithms. Question 25. In a queue, which operation removes the element at the front? A) enqueue() B) dequeue() C) peek() D) push() Answer: B Explanation: 'dequeue()' removes and returns the element at the front of the queue. Question 26. Which data structure is best suited for implementing a printer queue? A) Stack B) Queue C) Array

Data Structures Exam A

D) Linked list Answer: B Explanation: Queues follow FIFO order, suitable for scheduling print jobs. Question 27. Which type of linked list allows traversal in both directions? A) Singly linked list B) Doubly linked list C) Circular linked list D) Array Answer: B Explanation: Doubly linked lists have pointers to both next and previous nodes, enabling bidirectional traversal. Question 28. Which is an advantage of doubly linked lists over singly linked lists? A) Simpler implementation B) Easier traversal in both directions C) Uses less memory per node D) No need for pointers

Data Structures Exam A

Answer: B Explanation: Trees naturally represent hierarchical data, with parent-child relationships. Question 31. In a binary tree, what is the maximum number of children a node can have? A) 1 B) 2 C) 3 D) Unlimited Answer: B Explanation: By definition, a binary tree node can have at most two children. Question 32. Which traversal visits nodes in the order: root, left subtree, right subtree? A) Inorder B) Preorder C) Postorder D) Level order

Data Structures Exam A

Answer: B Explanation: Preorder traversal visits the root first, then left and right subtrees. Question 33. In a binary search tree (BST), where are smaller values stored relative to a node? A) Left subtree B) Right subtree C) Both subtrees equally D) In the parent node Answer: A Explanation: In BSTs, nodes with smaller values are stored in the left subtree, larger in the right. Question 34. Which operation in a BST can be used to find the minimum value? A) Search B) Insertion C) Min()

Data Structures Exam A

C) Dijkstra's algorithm D) Prim's algorithm Answer: B Explanation: DFS explores as deep as possible along each branch, backtracking when necessary. Question 37. Which algorithm is used to find the shortest path in a weighted graph with non-negative weights? A) Dijkstra’s algorithm B) BFS C) Kruskal’s algorithm D) Bellman-Ford algorithm Answer: A Explanation: Dijkstra’s algorithm efficiently computes the shortest path in graphs with non-negative edge weights. Question 38. Which sorting algorithm repeatedly swaps adjacent elements if they are in the wrong order? A) Selection Sort

Data Structures Exam A

B) Bubble Sort C) Merge Sort D) Quick Sort Answer: B Explanation: Bubble Sort compares and swaps adjacent elements to sort the array. Question 39. Which sorting algorithm has the best average-case time complexity among the listed options? A) Bubble Sort B) Selection Sort C) Insertion Sort D) Quick Sort Answer: D Explanation: Quick Sort has an average-case time complexity of O(n log n), making it faster on average. Question 40. Which sorting algorithm is stable and in-place? A) Merge Sort