Data Structure Quiz Review With Correct Answers 100% 2026
DATA STRUCTURE QUIZ REVIEW WITH CORRECT ANSWERS 100% 2026 What is an array (or list)? - Correct Answer An ordered collection of items A Facebook group has a group name and a collection of users as its members. The order of the members doesn't really matter, we only care if a member exists in the group or not. If we have the name of a group, we should be able to look up its members. Which data structure would best represent this scenario? - Correct Answer An Object that maps the group name (key) to a Set of members (value) What is the output from the following program? var groceries = { "bananas": 4, "apples": 5, "eggs": 12, "oranges": 1 }; function start(){ mystery("apples", "oranges"); println(s); } function mystery(one, two){ var temp = groceries[one]; groceries[one] = groceries[two]; groceries[two] = temp; } - Correct Answer 1 What is the output of the following program? var arr = [1, 2, 3, 4, 5]; var removed = e(2); println(arr); prinln(removed); - Correct Answer [1, 2, 4, 5] 3 We now want to write a function rowSums that, given a Grid, returns a list of the sums of each row of the Grid. So for example, if we had a Grid grid that looked like this: Then rowSums(grid) should return a list that looks like this: [19, 23, 49] Which of the following is the best implementation of rowSums? //choose the implementation of this function function rowSums(grid){ ... } function rowSum(grid, row){ //code from question 21 ... } - Correct Answer function rowSums(grid){ var sums = []; for(var row = 0; row Rows(); row++){ var sum = rowSum(grid, row); (sum); } return sums; } We are writing a program that needs to store a to-do list. The most important task should be at the beginning of the to-do list, and the least important task should be at the end of the to-do list. Which data structure should we use to store the to-do list? - Correct Answer List / Array We want to write a function isValidLocation(grid, row, col) that returns true if the specified row, col location is a valid location on the Grid grid Which of the following is the best implementation of isValidLocation? - Correct Answer function isValidLocation(grid, row, col){ return (row = 0 && row Rows()) && (col = 0 && col Cols()); } You are watching a basketball game and want to keep track of how many points each player scores. Which data structure should you use to store the name of each player and how many points they score? You want to be able to look up a player's score by their name. - Correct Answer Object/Map that maps strings of text (player names) to numbers (scores) What is a grid? - Correct Answer A co
Document information
- Uploaded on
- March 26, 2026
- Number of pages
- 9
- Written in
- 2025/2026
- Type
- Exam (elaborations)
- Contains
- Questions & answers