Docsity

CodeChef Certified Data Structure & Algorithms Programme (CCDSAP) Exam, Exams of Nursing

Toggle sidebar
bg1
1 | P a g e
CodeChef Certified Data Structure & Algorithms
Programme (CCDSAP) , based on the official
CCDSAP syllabus covering time and space
complexity, arrays, strings, recursion, searching,
sorting, linked lists, stacks, queues, trees, hashing,
heaps, graphs, dynamic programming, greedy
algorithms, and advanced problem-solving
techniques .
Important Note: Questions are in multiple-choice format, with
answers and explanations provided immediately after each question.
The exam is designed to test fundamental and advanced DSA
concepts.
---
## Questions 1–50: Time Complexity, Space Complexity & Algorithm
Analysis
Question 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download CodeChef Certified Data Structure & Algorithms Programme (CCDSAP) Exam and more Exams Nursing in PDF only on Docsity!

CodeChef Certified Data Structure & Algorithms

Programme (CCDSAP) , based on the official

CCDSAP syllabus covering time and space

complexity, arrays, strings, recursion, searching,

sorting, linked lists, stacks, queues, trees, hashing,

heaps, graphs, dynamic programming, greedy

algorithms, and advanced problem-solving

techniques.

Important Note: Questions are in multiple-choice format, with answers and explanations provided immediately after each question. The exam is designed to test fundamental and advanced DSA concepts.

Questions 1–50: Time Complexity, Space Complexity & Algorithm

Analysis Question 1

What is the time complexity of accessing an element in an array by its index? A) O(1) B) O(n) C) O(log n) D) O(n²) Correct Answer: A Explanation: Array indexing is O(1) because the memory address is calculated directly from the base address and index offset. Question 2 What is the time complexity of searching for an element in an unsorted array of size n? A) O(1) B) O(n) C) O(log n) D) O(n²) Correct Answer: B

Correct Answer: C Explanation: Bubble sort has O(n²) time complexity in both worst and average cases. Question 5 What does Big O notation describe? A) The exact number of operations B) The upper bound of the growth rate of an algorithm C) The lower bound of the growth rate of an algorithm D) The best-case performance Correct Answer: B Explanation: Big O notation describes the asymptotic upper bound of an algorithm's growth rate. Question 6 Which of the following has the lowest asymptotic growth rate? A) O(n!) B) O(2ⁿ) C) O(n log n)

D) O(log n) Correct Answer: D Explanation: O(log n) grows slower than O(n log n), O(2ⁿ), and O(n!). The hierarchy is: O(log n) < O(n) < O(n log n) < O(n²) < O(2ⁿ) < O(n!). Question 7 What is the time complexity of binary search on a sorted array of size n? A) O(1) B) O(n) C) O(log n) D) O(n²) Correct Answer: C Explanation: Binary search repeatedly halves the search space, leading to O(log n) time. Question 8 If an algorithm runs in O(n²), what happens to the running time when the input size doubles?

Question 10 Which of the following represents the best-case time complexity of insertion sort? A) O(1) B) O(n) C) O(n log n) D) O(n²) Correct Answer: B Explanation: In the best case (array already sorted), insertion sort only needs to scan and compare, taking O(n) time.

Questions 51–100: Arrays, Strings & Linked Lists

Question 51 What is the time complexity of inserting an element at the beginning of a singly linked list? A) O(1) B) O(n)

C) O(log n) D) O(n²) Correct Answer: A Explanation: You only need to create a new node, set its next to the current head, and update the head pointer — no traversal required. Question 52 Which data structure is best suited for implementing a Last-In-First- Out (LIFO) behavior? A) Queue B) Stack C) Priority queue D) Deque Correct Answer: B Explanation: A stack follows LIFO order; a queue follows FIFO order. Question 53 What is the worst-case time complexity for searching for an element in a singly linked list?

Which of the following is NOT an advantage of a doubly linked list over a singly linked list? A) Easier to traverse backward B) Easier to delete a given node when only the node pointer is known C) Uses less memory D) Allows insertion before a given node in O(1) time Correct Answer: C Explanation: Doubly linked lists require an extra pointer (prev), so they use more memory than singly linked lists. Question 56 The time complexity to insert a new node at a known position in a singly linked list (given a pointer to the previous node) is: A) O(1) B) O(n) C) O(log n) D) O(n²) Correct Answer: A

Explanation: If you already have the pointer to the previous node, insertion takes constant time. Question 57 Which data structure is best for implementing a First-In-First-Out (FIFO) behavior? A) Stack B) Queue C) Priority queue D) Graph Correct Answer: B Explanation: A queue implements FIFO order. Question 58 The time complexity of accessing the middle element of a singly linked list of size n (without maintaining a middle pointer) is: A) O(1) B) O(n) C) O(log n) D) O(n²)

A) O(1)

B) O(n) C) O(log n) D) O(n²) Correct Answer: B Explanation: You must traverse the entire list to count nodes, which is O(n).

Questions 101–150: Stacks, Queues & Recursion

Question 101 Which data structure is commonly used to implement recursion? A) Queue B) Stack C) Array D) Hash table

Correct Answer: B Explanation: Recursion uses the call stack to store activation records for each function call. Question 102 The worst-case space complexity of recursive binary search (without tail recursion) is: A) O(1) B) O(log n) C) O(n) D) O(n²) Correct Answer: B Explanation: Each recursive call stores its state on the stack; binary search depth is log n. Question 103 Which of the following problems can be efficiently solved using a stack? A) Checking for balanced parentheses B) Computing the factorial of a number

A) Stack B) Queue C) Priority queue D) Array Correct Answer: B Explanation: BFS uses a queue to process nodes in FIFO order. Question 106 A circular queue is implemented to: A) Reduce memory usage B) Improve CPU caching C) Reuse empty spaces in a fixed-size array D) Support LIFO operations Correct Answer: C Explanation: A circular queue uses a fixed-size array and wraps around to reuse empty slots. Question 107

Which of the following is NOT a real-world application of a stack? A) Function call management B) Undo/Redo feature in text editors C) Page replacement algorithms in OS D) Expression evaluation (infix to postfix) Correct Answer: C Explanation: Page replacement uses algorithms like LRU, typically implemented with queues or hashing. Question 108 The dequeue operation in a queue implemented using a singly linked list (with front and rear pointers) has what time complexity? A) O(1) B) O(n) C) O(log n) D) O(n²) Correct Answer: A Explanation: If front points to the first node, removing it is O(1).

Explanation: Stack trace:

  • Push 1 → [1]
  • Push 2 → [1,2]
  • Pop → removes 2
  • Push 3 → [1,3]
  • Pop → removes 3
  • Pop → removes 1 (final output 1)

Questions 151–200: Trees, Heaps & Hashing

Question 151 What is the time complexity of searching for a value in a binary search tree (BST) in the worst case? A) O(1) B) O(log n) C) O(n) D) O(n log n)

Correct Answer: C Explanation: In a skewed BST (resembling a linked list), search degrades to O(n). Question 152 In a min-heap, the smallest element is always found at: A) The last leaf node B) The root node C) Any leaf node D) The rightmost node Correct Answer: B Explanation: A min-heap maintains the smallest element at the root. Question 153 A perfect hash function is one that: A) Maps every key to a unique slot B) Uses the most memory C) Creates many collisions D) Uses O(n²) time to compute the hash