Data Structures Final True/ False

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

T/F: When analyzing a search algorithm, we count the number of key comparisons because this number gives us the most useful information.

True

T/F: From the binary search algorithm, it follows that every iteration of the while loop cuts the size of the search list by half.

True: The whole point of binary searching

T/F: The number of key comparisons in a sequential search depends on the value of the search item.

True: Time complexity is constant

When "star" is used as a unary operator, "star" refers to the object to which the operand of the "*" (that is, the pointer) points.

True: derefference operator

In a shallow copy, two pointers of different data types point to the same memory

False

T/F: A linked list is a random access data structure such as an array.

False: Must search starting at the beginning

T/F: The bottom element of the stack is the last element added to the stack.

False: The bottom element is the first added to the stack. First in last out

T/F: The elements at the top of the stack have been in the stack the longest.

False: The top is the latest element added.

T/F: The item added to the stack last will be the item removed last.

False: They will be removed first. Last in first out

T/F: The time-complexity of the copyStack function is O(1).

False: Time complexity is linear. Gotta copy each element over

Two different pointer variables cannot point to same memory location.

False: Two of the same type can point to same address-> size of the bytes

T/F: Recursive algorithms are implemented using while loops.

False: Uses If / else statement. Iterative uses loops

The components of a class are called objects.

False: members

In C++, every object of a class maintains a hidden pointer to itself, and the name of this pointer is "hidden"

False: name is "this"

The ampersand, &, is a binary operator that returns the address of its operand.

False: not a binary operator->uniary operator

T/F: In general, there are three types of linked lists and they are: sorted, unsorted and mixed.

False: sorted, singerly linked, doubly linked

When a dynamic variable is no longer needed, it can be destroyed; that is, its memory can be deallocated.

True

When a program no longer needs a dynamic variable, the operator delete is used.

True

T/F: To design a working recursive function, you must determine the limiting conditions.

True: Limiting conditions are the conditions that satisfy the base case

In C++, the mechanism that allows you to combine data and the operations on that data in a single unit is called a class.

True: each class contains data and operations

In C++ the user can create new operators

False: we can override them

T/F: Recursion is a very powerful way to solve certain problems for which the solution would otherwise be more complicated to code.

True (Recursive are more intuitive than iterative)

T/F: Stacks can be used to print a list backwards without using recursion.

True: Last in first out concept

T/F: The link component of each node is a pointer.

True

T/F: To access the fifth element in a list, we must first traverse the first four elements.

True

Software engineers typically break the software development process into the following four phases: analysis, design, implementation, and testing and debugging.

True

T/F: A general solution to a recursive algorithm must eventually reduce to a base case.

True

T/F: A stack is called a LIFO data structure.

True

T/F: Every node in a linked list has two components: one to store the relevant information and one to store the address.

True

T/F: Logically, you can think of a working recursive function as having an unlimited number of copies of itself and never stops.

False: If it never stops, it's not working and then you have infinite recursion

Class objects cannot be passed as parameters to functions or returned as function values.

False: It can

A derived class inherits all its data members from the base class; it has none of its own.

False: It can have its own

T/F: The recursive algorithm must have three or more base cases.

False: Just need one base case but you can have more

T/F: A recursive solution is always a better alternative to an iterative solution.

False: Depends on the situation and what you needs are for straight forward answer as opposed to time complexity

The increment operator increments the value of a pointer variable by twice the size of the memory to which it is pointing.

False

The three fundamental stages through which a program goes are implementation, use, and maintenance.

False: 4 stage

When an integer is added to a pointer variable, the value of the pointer variable is incremented by the integer times the size of the memory to which the pointer is pointing.

True

When overloading an operator, you might define the meaning of how the operator works with the related object.

True

T/F: In a linked list implementation of a stack, only a fixed number of elements can be pushed onto the stack.

False: Linked list you can push as many elements as you want

T/F: . The recursive process in a recursive function starts with the base case.

False: Looking at the general case first that then reduces to a base case. This is not the actual code just looking at the process

T/F: Operations such as search, insert, and delete require a linked list to be sorted.

False: Not required to be sorted

T/F: Building a linked list backwards places the new item to be added at the end of the linked list.

False: Places the new item to be added at the beginning of the linked list

T/F: Building a linked list forward places the new item to be added at the beginning of the linked list.

False: Places the new item to be added at the end of the linked list

T/F: The operation pop returns the top element of the stack without removing it.

False: Pop removes element

T/F: The sequential search always starts at the last element in the list and continues until either the item is found in the list or the entire list is searched.

False: Starts sometimes with the first element

T/F: The general case in a recursive function is the case for which the solution is obtained directly.

False: The base case gives solution directly

T/F: You cannot write a recursive algorithm to implement a sequential search algorithm.

False: We did a practice coding using recursion to search

T/F: The best and worst cases are likely to occur most of the time that we apply the sequential search on a list.

False: We look at average cases because they are more likely to occur

T/F: Prior to the addQueue operation, the queue must exist and must not be empty.

False: You are adding an element to a queue. Does not need to be empty but needs to exist.

T/F: A queue cannot be implemented using in an array.

False: You can use an array

A friend function is a member function of a class but only has access to the class's public data members

False: can access private

A class and its members can be described graphically using a notation known as Unified Modeling Language (UML) notation

True

A derived class can directly access the protected members of a base class

True

A program goes through many phases from the time it is first conceived until the time it is retired, called the life cycle of the program.

True

As parameters to functions, class objects can be passed only by reference.

True

By using templates, you can write a single code segment for a set of related functions

True

Composition is a "has-a" relationship

True

Default arguments can be used with an overloaded operator

True

If g(n) = 1, the growth rate is constant and does not depend on the size of the problem

True

In OOP, each object consists of data and operations on that data.

True

In a deep copy, two or more pointers have their own data

True

In multiple inheritance, the derived class is derived from more than one base class

True

In single inheritance, the derived class is derived from a single base class.

True

Inheritance is an ''is-a''relationship.

True

OOD has three basic principles: encapsulation, inheritance and polymorphism

True

Overriding a member function is the same as redefining it.

True

T/F: An array is a random access data structure; a stack is not.

True

T/F: An element can be removed from the stack only if there is something in the stack, and an element can be added to the stack only if there is room.

True

T/F: Because the size of the array to store elements is fixed, only a finite number of elements can be stored in a queue that is implemented using an array.

True

T/F: Every recursive call has its own copy of code of the recursive function.

True

T/F: Header/first and trailer/last nodes are considered part of a linked list.

True

T/F: If every recursive call will result in another recursive call, then the recursive function (algorithm) is said to have infinite recursion.

True

T/F: In a doubly linked list, every node contains the address of the next node (except the last node), and every node contains the address of the previous node (except the first node).

True

T/F: The address of the first node in a linked list is stored in a separate location/pointer, called the head.

True

T/F: The call to the recursive function contains a statement that causes the same function to execute again before completing the current function call.

True

T/F: The operation top returns the top element of the stack without removing it.

True

T/F: The queue operation isFullQueue determines whether the queue is full.

True

T/F: To delete a given item from an ordered linked list, there may be no need to search the list to see whether the item to be deleted is in the list.

True

The decrement operator decrements the value of a pointer variable by the size of the memory to which it is pointing.

True

The function that overloads any of the operators (), [], ->, or = for a class must be declared as a member of the class.

True

The term asymptotic means the study of the function f as n becomes larger and larger

True

The values belonging to pointer data types are the memory addresses of your computer

True

T/F: The analysis of algorithms enables programmers to decide which algorithm to use for a specific application.

True

T/F: The execution of the recursive version of the program to calculate a Fibonacci number is as efficient as the execution of the non-recursive version.

False: Last project proved this incorrect

When an integer is subtracted from a pointer variable, the value of the pointer variable is decremented by the integer times half the size of the memory to which the pointer is pointing.

False

When writing the definition of a friend function, the name of the class and the scope resolution operator do not precede the name of the friend function in the function heading.

False: :: is the scope operator

T/F: The operation push removes the bottom element from the stack.

False: Adds an element to the top of the stack

T/F: Each node of a singly linked list has at least four components.

False: At least two components

T/F: We can traverse a singly linked list backward starting from the last node to the first node.

False: Can traverse backwards with doubly using previous pointer

T/F: The general rule to process elements in a queue is that the customer at the end/rear of the queue is served next and that when a new customer arrives, he or she stands at the front of the queue.

False: Customer at front is served first. New customers go to rear/end of queue. First in first out

T/F: The algorithms to implement the operations search, insert, and remove are the same for sorted and unsorted list.

False: Different implementation

T/F: A doubly linked list is a linked list in which every node has a next pointer and a null pointer.

False: Has a previous pointer instead of null

T/F: A function that calls itself is an iterative function.

False: It's called a recursive function


Kaugnay na mga set ng pag-aaral

Mod 7 DHCPv4 HW Homework in Homework

View Set

M9 Life Insurance and Investment-linked policies - Chapter 6 Participating Life Insurance Policies

View Set

SFDC Sales Cloud Certification - NaBil

View Set

Chapter 13: Integrative Physiology I: Control of Body Movement

View Set

008 - Networking - C11.1. WAN Concepts / Questions

View Set