Quiz 2 Practice

Quiz 2 Practice

University

5 Qs

quiz-placeholder

Similar activities

DFC30233 - Chapter 3

DFC30233 - Chapter 3

University

10 Qs

C++ linked list

C++ linked list

University

10 Qs

Linked List 2

Linked List 2

University

10 Qs

Quiz 1 - AK2 Section

Quiz 1 - AK2 Section

University

10 Qs

Linkedlist

Linkedlist

University

10 Qs

DS QUIZ-1 (unit-1)

DS QUIZ-1 (unit-1)

University

10 Qs

CSC248 Revision 1

CSC248 Revision 1

University

10 Qs

Stack

Stack

University

10 Qs

Quiz 2 Practice

Quiz 2 Practice

Assessment

Quiz

Computers

University

Easy

Created by

Remo Mahmoud

Used 6+ times

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

One advantage of a doubly linked list over a singly linked list is that insertion and deletion is more efficient.

True

False

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

A subclass can access the private members of its superclass.

True

False

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

A class template cannot have more than one typename.

True

False

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What is the output of the following code fragment?

13

7

Infinite loop

17

5.

OPEN ENDED QUESTION

3 mins • 1 pt

Write down the function addFront in class CircleList which takes one argument: An element “e” of type int, passed by reference.

The function creates a new node and puts element “e” in it, and then inserts the newly-created node at the front of the circularly linked list.

Evaluate responses using AI:

OFF

Answer explanation

void CircleList::addFront(int& e) {

    CNode* v = new CNode; // create a new node

    v−>elem = e;

    // handling the special case when the list is empty

    if (cursor == NULL){

        v−>next = v; // v points to itself

        cursor = v;

    }

    // if the list is not empty

    else {

        v−>next = cursor−>next;

        cursor−>next = v;

    }

}