Which Of The Following Best Describes The Growth Of A Linear #130
Which of the following best describes the growth of a linear queue at runtime? (Q is the original queue, size() returns the number of elements in the queue)
This multiple choice question (MCQ) is related to the book/course gs gs121 Data Structures and Algorithms. It can also be found in gs gs121 Abstract Data Types - Queue using Array - Quiz No.1.
Which of the following best describes the growth of a linear queue at runtime? (Q is the original queue, size() returns the number of elements in the queue)
private void expand() { int length = size(); int[] newQ = new int[length<<1]; for(int i=front; i<=rear; i++) { newQ[i-front] = Q[i%CAPACITY]; } Q = newQ; front = 0; rear = size()-1; }
private void expand() { int length = size(); int[] newQ = new int[length<<1]; for(int i=front; i<=rear; i++) { newQ[i-front] = Q[i%CAPACITY]; } Q = newQ; }
private void expand() { int length = size(); int[] newQ = new int[length<<1]; for(int i=front; i<=rear; i++) { newQ[i-front] = Q[i]; } Q = newQ; front = 0; rear = size()-1; }
private void expand() { int length = size(); int[] newQ = new int[length*2]; for(int i=front; i<=rear; i++) { newQ[i-front] = Q[i%CAPACITY]; } Q = newQ; }
Similar question(s) are as followings:
Online Quizzes of gs121 Data Structures and Algorithms
Binary Trees - Binary Search Tree - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Binary Search Tree - Quiz No.2
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Preorder Traversal - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes