โ† All CCS Flashcard Decks

Data Structures and Algorithms Flashcards

7 cards from real CCS practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Data Structures and Algorithms flashcards as text
  1. What property distinguishes a max-heap from a min-heap?

    Answer: Max-heap has the largest element at the root; min-heap has the smallest

    In a max-heap the root is always the maximum element, while in a min-heap the root is always the minimum.

  2. Which graph representation is most space-efficient for a sparse graph?

    Answer: Adjacency list

    An adjacency list uses space proportional to the number of edges, which is efficient for sparse graphs.

  3. What is the purpose of dynamic programming?

    Answer: To avoid recomputing overlapping subproblems by storing results

    Dynamic programming stores solutions to overlapping subproblems (memoization or tabulation) to avoid redundant computation.

  4. In a doubly linked list, each node contains:

    Answer: Two pointers: one to the next and one to the previous node

    A doubly linked list node holds data plus pointers to both the next and previous nodes, enabling bidirectional traversal.

  5. What is the time complexity of inserting an element at the beginning of a singly linked list?

    Answer: O(1)

    Inserting at the head of a linked list only requires updating one pointer, which is O(1).

  6. Which algorithm finds the shortest path in a weighted graph with non-negative edges?

    Answer: Dijkstra's algorithm

    Dijkstra's algorithm greedily finds shortest paths from a source in graphs with non-negative edge weights.

  7. What is a collision in the context of hash tables?

    Answer: Two keys map to the same index

    A collision occurs when two different keys produce the same hash index, requiring a resolution strategy like chaining or open addressing.