1. Home
  2. Explore
  3. Computer Science
  4. Data Structures Introduction

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Data Structures Introduction

  • 70Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Data Structures Overview
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is a data structure in computer science?

Tap to flipClick to flipspace

A way to store, organize, and manage information or data so that you can easily access or modify the values within it.

Or swipe the card

70 cards

  1. What is a data structure in computer science?

    A way to store, organize, and manage information or data so that you can easily access or modify the values within it.

  2. What are the two main categories of data structures based on how elements are accessed?

    Random access (each element can be accessed directly in constant time) and sequential access (elements can only be accessed in a particular order).

  3. Why is big O notation used in computer science?

    To score a data structure or algorithm based on the number of operations it takes to complete a task, independent of hardware speed.

  4. What are the four criteria used to measure the efficiency of a data structure using big O notation?

    Accessing, searching, inserting, and deleting elements.

  5. In big O notation, which scenario is always used when evaluating a data structure?

    The worst-case scenario.

  6. What does O(1)O(1)O(1) mean in terms of time complexity?

    Constant time: the number of operations required does not change regardless of the size of the data set.

  7. What is the time complexity equation O(log⁡n)O(\log n)O(logn) and what does it represent?

    Logarithmic time: the number of operations increases slowly as the data set grows, giving more efficiency for larger data sets.

  8. What does O(n)O(n)O(n) time complexity mean?

    Linear time: the number of operations grows directly proportional to the size of the data set (nnn).

  9. What are the six most common time complexity equations from most efficient to least efficient?

    O(1)O(1)O(1), O(log⁡n)O(\log n)O(logn), O(n)O(n)O(n), O(nlog⁡n)O(n \log n)O(nlogn), O(n2)O(n^2)O(n2), O(2n)O(2^n)O(2n).

  10. What are the three attributes of an array?

    Name (to reference the array), type (the data type of elements), and size (fixed number of elements).

  11. Can an array hold different types of data?

    No, an array can only hold elements of the same data type.

  12. Can the size of an array be changed after creation?

    No, the size of an array is fixed and cannot be changed using conventional methods.

  13. How do you reference the first element in an array?

    Using index 0 (e.g., arrayName[0]).

  14. What is a two-dimensional array?

    An array whose elements are also arrays, creating a matrix-like structure with rows and columns.

  15. What are the time complexities for an array: access, search, insert, and delete?

    Access: O(1)O(1)O(1), Search: O(n)O(n)O(n), Insert: O(n)O(n)O(n), Delete: O(n)O(n)O(n).

  16. Why is accessing an array element O(1)O(1)O(1)?

    Because elements are stored contiguously in memory, so the computer can calculate the memory address of any element by adding the index times element size to the base address.

  17. What is an ArrayList?

    A resizeable array that dynamically expands as elements are added. It is backed by an array in memory.

  18. Name six common methods of the ArrayList class.

    add(), remove(), get(), set(), clear(), toArray().

  19. How does the add() method work in an ArrayList?

    It has two forms: one appends an object to the end, and another inserts an object at a specified index, shifting subsequent elements to the right.

  20. What is auto-boxing in the context of ArrayLists?

    The automatic conversion of a primitive type (e.g., int) into its corresponding wrapper object (e.g., Integer) when adding to an ArrayList.

  21. What is the time complexity for accessing an element in an ArrayList?

    O(1)O(1)O(1).

  22. Compare arrays and ArrayLists: which allows dynamic resizing?

    ArrayLists allow dynamic resizing; arrays have fixed size.

  23. What is the LIFO principle in a stack?

    Last In, First Out: the element added last is the first one to be removed.

  24. Name the two fundamental methods of a stack and describe what they do.

    push() adds an element to the top; pop() removes and returns the top element.

  25. What does the peek() method do on a stack?

    Returns the top element without removing it.

  26. What are the time complexities for a stack: access, search, insert, delete?

    Access: O(n)O(n)O(n), Search: O(n)O(n)O(n), Insert: O(1)O(1)O(1), Delete: O(1)O(1)O(1).

  27. Give two real-world examples of stack usage in computing.

    The undo/redo functionality in word processors and the back button in web browsers.

  28. What is the FIFO principle in a queue?

    First In, First Out: the element added first is the first one to be removed.

  29. Name the two fundamental methods of a queue and describe what they do.

    enqueue() adds an element to the tail (back); dequeue() removes and returns the element from the head (front).

  30. What are the time complexities for a queue: access, search, insert, delete?

    Access: O(n)O(n)O(n), Search: O(n)O(n)O(n), Insert: O(1)O(1)O(1), Delete: O(1)O(1)O(1).

  31. Give two real-world examples of queue usage in computing.

    Job scheduling by the operating system and managing print jobs for a printer.

  32. What is a linked list?

    A sequential access linear data structure where each element is a node containing data and a reference (pointer) to the next node.

  33. What are the two parts of a node in a singly linked list?

    The data (the actual information) and the pointer (reference to the next node in the list).

  34. How do you add a node to the head of a linked list?

    Set the new node's pointer to point to the current head, then designate the new node as the head.

  35. How do you insert a node into the middle of a linked list?

    First, set the new node's pointer to point to the node after the insertion point. Then, set the previous node's pointer to the new node.

  36. What are the time complexities for a linked list: access, search, insert at head, insert at known position?

    Access: O(n)O(n)O(n), Search: O(n)O(n)O(n), Insert at head: O(1)O(1)O(1), Insert at a given (traversed) position: O(1)O(1)O(1) for pointer adjustment but O(n)O(n)O(n) to reach that position.

  37. Name one important use of linked lists in computer science.

    They are used as the backing data structure for implementing stacks and queues.

  38. What distinguishes a doubly linked list from a singly linked list?

    Each node in a doubly linked list has two pointers: one pointing to the next node and one pointing to the previous node.

  39. How many pointers need to be updated when inserting a node into the middle of a doubly linked list?

    Four: the new node's next and previous, the previous node's next, and the following node's previous.

  40. What are the time complexities for a doubly linked list (same as singly)?

    Access: O(n)O(n)O(n), Search: O(n)O(n)O(n), Insert/Delete at head or tail: O(1)O(1)O(1), Insert/Delete in middle: O(n)O(n)O(n) due to traversal.

  41. Give an application of doubly linked lists.

    Browser history navigation (back and forward), undo/redo functionality, open recent files.

  42. What is a dictionary (map/associative array) in computer science?

    An abstract data structure that stores data in key-value pairs, where each key is unique and maps to exactly one value.

  43. What are two restrictions on keys in a dictionary?

    Each key must be unique, and each key can have only one value associated with it.

  44. What is a hash table?

    A data structure that uses a hash function to map keys to specific indices in an array, providing efficient lookup.

  45. What is a hash collision?

    When two different keys produce the same hash value (index) from the hash function.

  46. Name two methods to resolve hash collisions.

    Open addressing (find the next available empty slot) and closed addressing (chain multiple keys in a linked list at the same index).

  47. What are the time complexities for a dictionary with a good hash function?

    Average case: O(1)O(1)O(1) for access, search, insert, delete. Worst case: O(n)O(n)O(n) (if all keys collide).

  48. What is a tree in computer science?

    A nonlinear, hierarchical data structure consisting of nodes (vertices) connected by edges. It has a root, branches, and leaves.

  49. Define: root node, parent node, child node, leaf node.

    Root: topmost node. Parent: node with at least one child. Child: node directly connected to a parent above. Leaf: node with no children.

  50. What is the height of a tree?

    The number of edges on the longest path from the root to a leaf.

  51. What is the depth of a node?

    The number of edges from the root to that node.

  52. What is a binary search tree (BST)?

    A binary tree where each node has at most two children, the left child has a value less than or equal to the parent, the right child has a value greater than or equal to the parent, and no duplicates are allowed.

  53. What is the search time complexity in a balanced BST?

    O(log⁡n)O(\log n)O(logn).

  54. What is a trie (prefix tree)?

    A tree-like data structure where each node stores a character, and words are formed by paths from the root to nodes marked as end-of-word.

  55. How does a trie handle word endings?

    By using a flag (e.g., a special character like asterisk) at nodes that represent the end of a word.

  56. Give two applications of tries.

    Autocomplete suggestions on smartphones and spellcheck in word processors.

  57. What is a heap?

    A special type of tree where parent nodes have a specific relationship with their children: either min-heap (parent <= children) or max-heap (parent >= children).

  58. In a min-heap, where is the smallest element located?

    At the root.

  59. Describe the process of inserting a new element into a max-heap.

    Add the element at the leftmost available position in the last level, then repeatedly swap it with its parent until the max-heap property is restored (the element is smaller than its parent).

  60. Describe the process of deleting the root from a heap.

    Replace the root with the last element (rightmost in the last level), remove the last element, then repeatedly swap the new root with its largest child (for max-heap) until the heap property is restored.

  61. What is heapsort?

    A sorting algorithm that builds a heap from the input list, then repeatedly removes the root (max or min) and places it at the end of a sorted list, re-heapifying each time.

  62. What is a priority queue and how does it relate to heaps?

    A priority queue is a data structure that allows efficient removal of the highest priority element. Heaps are commonly used as the underlying implementation.

  63. What is a graph in computer science?

    A nonlinear data structure consisting of a set of vertices (nodes) and a set of edges (connections between vertices).

  64. How is a graph formally represented?

    By a vertex set VVV and an edge set EEE where each edge is an ordered pair (u,v)(u, v)(u,v) indicating a connection between vertices uuu and vvv.

  65. What does it mean for two vertices to be adjacent in a graph?

    They are directly connected by an edge.

  66. What is the difference between an undirected graph and a directed graph?

    In an undirected graph, edges have no direction (bidirectional). In a directed graph, edges have a direction (from one vertex to another).

  67. What makes a graph cyclic?

    A graph is cyclic if there exists a path from at least one vertex back to itself (a cycle).

  68. What is a weighted graph?

    A graph where each edge has an associated numerical value (weight), often representing cost, distance, or capacity.

  69. Name a famous algorithm that uses weighted graphs and its application.

    Dijkstra's shortest path algorithm, used in Google Maps to find the shortest route.

  70. How can graphs be used to model social networks?

    Users are vertices, and friendships/follows are edges. Undirected for mutual friendships (Facebook), directed for one-way follows (Instagram).

Card 1 of 70
Card 1 of 70

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent