Final Flashcards

Learn

1
Q

What is the significance of selecting appropriate data structures and algorithms in software development?

A

It can significantly impact the speed and efficiency of the software.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which data structure is best suited for implementing a stack?

A

Linked list (or Array, as both are commonly used depending on the specific requirements and constraints)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does it mean for an abstract data type to be “abstract”?

A

It hides the implementation details from the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does the time complexity of an algorithm affect its efficiency?

A

Algorithms with lower time complexity are always more efficient.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do data structures and algorithms contribute to the efficiency of a program?

A

Data structures and algorithms both play crucial roles in optimizing program performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Two arrays, itemsNames and itemsPrices, are used to store a list of item names and their corresponding prices. Which is true?

A

Both arrays should be declared to have the same number of elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Given an array with values 5, 10, 15, 20, 25, what are the fewest number of swaps needed to reverse the list?

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Given array scorePerQuiz has 10 elements. Which assigns element 7 with the value 8?

A

scorePerQuiz[7] = 8;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which is an invalid access for the array?

int[] numList = new int[5];
int x = 3;

A
  • numsList[x-3]
  • numsList[0]
  • numsList[x+2]
  • numsList[(2*x) - x]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Given that integer array x has elements 4, 7, 3, 0, 8, what are the elements after the loop?

int i;
for (i = 0; i < 4; ++i) {
x[i] = x[i + 1];
}

A

7, 3, 0, 8, 8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which list is sorted into ascending order?

  • Sally, Sam, Sandy, Samantha, Sal
  • Ral, Reece, Rita, Ryan
  • Don, Dan, Dale, Dana
  • Alan, Andy, Al, Adam
A

Ral, Reece, Rita, Ryan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Given the number list (2, 12, 8, 19, 5, 30), identify the merged list in merge sort after the completion of the second level.

  • (2, 12, 8) and (5, 19, 30)
  • (2, 8, 12) and (5, 19, 30)
  • (2, 5, 8) and (12, 19, 30)
  • (2, 12, 8) and (19, 5, 30)
A

(2, 8, 12) and (5, 19, 30)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In selection sort, the smallest element is selected and swapped with the _____ unsorted element.

  • next
  • middle
  • leftmost
  • rightmost
A

leftmost

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which of the following is the fastest algorithm to sort a string?

  • Selection Sort
  • Insertion Sort
  • Shell Sort
  • Merge Sort
A

Merge Sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the following is not an example of sorting a list?

  • Arranging patient records alphabetically
  • Arranging employee details based on beginning dates
  • Arranging student records neatly on a desk
  • Arranging musical instruments based on the number of strings they have
A

Arranging student records neatly on a desk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which of the following sorting algorithms cannot be performed on a doubly-linked list?

15
Q

Given the singly-linked list (10, 20, 30, 40, 50, 60), what commands remove 10, 20, and 60, such that the final list is (30, 40, 50)?

-ListRemoveAfter(list, null) ListRemoveAfter(list, node 10) ListRemoveAfter(list, node 50)

  • ListRemoveAfter(list, null) ListRemoveAfter(list, node 20) ListRemoveAfter(list, node 60)
  • ListRemoveAfter(list, null) ListRemoveAfter(list, null) ListRemoveAfter(list, node 60)
  • ListRemoveAfter(list, null) ListRemoveAfter(list, null) ListRemoveAfter(list, node 50)
A

ListRemoveAfter(list, null) ListRemoveAfter(list, node 10) ListRemoveAfter(list, node 50)

16
Q

In a singly-linked list with 1 element, the tail pointer ____ and the next pointer of the head node ____.

A

Points to the head node, is null

17
Q

Given the list Students: Tom, Harry, Sam, Kim, Tina, Hal, Sally. What will be the value of the next pointer of the node Hal if the node Sally is removed from the list?

Null
Reference of Tom
Reference of Tina
Reference of Sally

18
Q

In the ListInsertAfter function for singly-linked lists, the curNode parameter points to _____ node.

A

any existing