Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Data Structures Interview Questions C++ Data Structure Runtimes Data Structure Insert Find Delete vector O(n) O(1) amortized O(n) O(1) if index is known O(n) sorted vector O(n) O(log(n)) O(n) linked list (list, stack, queue) O(1) *Given an Iterator O(n) O(1) *Given an Iterator balanced binary tree (map, set) O(log(n)) O(log(n)) O(log(n)) hash table (unordered_set, unordered_map) O(1) O(1) O(1) Heap (priority_queue) O(log(n)) N/A O(1) to find min O(log(n)) Common Interview Questions • *These types of questions will not be on the final exam • Find the middle element of a linked list in one pass. • What if the list has a cycle? • Detect a cycle in a linked list. Common Interview Questions • *These types of questions will not be on the final exam • Given an array of size 100 containing one copy each of the integers 1-100 with exactly one integer being repeated once, find the repeated integer. • Given an array of arbitrary integers, find all integers that appear exactly twice. Common Interview Questions • *These types of questions will not be on the final exam • Implement a stack that can also give the minimum element in the stack at any given time. push, pop, and min must all run in O(1) time. Common Interview Questions • *These types of questions will not be on the final exam • In class we described a stack that was implemented as a linked list. How could we implement a stack as a vector? • How could we use a single vector to implement 3 stacks? Common Interview Questions • *These types of questions will not be on the final exam • Give a function that will sort a vector of string such that all the anagrams are next to each other, ignoring spaces. – Two words are anagrams of each other if they use exactly the same letters – ex. “interpreter” and “enter err pit”