Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
S and Q are integer stacks and priority queues, respectively. C mod 3 is the priority of an element C joining the priority queue Q. In other words, the elements' priority numbers are either 0 or 1 or 2. What is the output of the following code if A, B, and C are integer variables? However, the queue procedures have been modified to work on a priority queue.
1.A = 10
2.B = 11
3.C = A+B
4.while (C < 110) do
5. if (C mod 3) = 0 then PUSH (S,C)
6. else ENQUEUE (Q,C)
7. A = B
8. B = C
9. C = A + B
10.end
11.while not EMPTY_STACK (S) do
12. POP (S,C)
13. PRINT (C)
14.end
15.while not EMPTY_QUEUE (Q) do
16. DEQUEUE (Q, C)
17. PRINT (C)
18.end
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Assume a linked list contains following integers: 7, 2, x, 5, 8, x, 15 and the pointer head is pointing to the first node of the list. What will be the value of variable a after the following statements are executed: Node<int> *curNode=head; curNode=curNode->getNext(); curNode=curNode->getNext(); int a; a=curNode->getItem(); 1. x 2. 2 3. 7 4. x+9arrow_forwardWhite a Java Function to find unique number in a list ls = [ 2, 3, 4, 10, 5, 6, 6, 4, 10, 3 ] , unique number is number that doesn't repeat this case unique list will be = [ 2, 5 ]arrow_forwardInput : 1->2->3->2->1->NULL Output: It's a palindrome !!! Create a palindrome of your student ID and then push the element to the stack and queue. Pop each element from the stack and the queue and then check for the mismatch.arrow_forward
- A queue and a deque data structure are related concepts. Deque is an acronym meaning "double-ended queue." With a deque, you may insert, remove, or view from either end of the queue, which distinguishes it from the other two. Use arrays to implement a dequearrow_forward'Split List' in Scheme:arrow_forwardvoid listEmployees (void) { for (int i=0; i 10000. Make a guess about why the comparison function takes 2 struct Employee parameters (as opposed to struct Employee *) **arrow_forward
- In C++, – Implement a Priority queue using a SORTED list. Use Quick sort after adding a new node. Create a class called Node: Have a Name and Priority.Data set - 1 is the highest priority, 10 is lowest priority.Enqueue and dequeue in the following order.Function Name, PriorityEnqueue Joe, 3Enqueue Fred, 1Enqueue Tuyet, 9Enqueue Jose, 6DequeueEnqueue Jing, 2Enqueue Xi, 5Enqueue Moe, 3DequeueEnqueue Miko, 7Enqueue Vlady, 8Enqueue Frank, 9Enqueue Anny, 3DequeueEnqueue Xi, 2Enqueue Wali, 2Enqueue Laschec, 6Enqueue Xerrax, 8DequeueDequeueDequeueDequeueDequeueDequeueDequeueDequeueDequeueDequeueDequeuearrow_forwardWrite a program in Java to manipulate a Singly Linked List: Count the number of nodes Insert a new node before the value 5 of Singly Linked List Search an existing element in a Singly linked list (the element of search is given by the user) Suppose List contained the following Test Data: Input data for node 1: 2Input data for node 2 : 3Input data for node 3 : 5 Input data for node 4: 8arrow_forwardIn C++, write a program that reads in an array of type int. You may assume that there are fewer than 20 entries in the array. The output must be a two-column list. The first column is a list of the distinct array elements and the second column is the count of the number of occurences of each element.arrow_forward
- #include <iostream> using namespace std; #define SIZE 5 //creating the queue using array int A[SIZE]; int front = -1; int rear = -1; //function to check if the queue is empty bool isempty() { if(front == -1 && rear == -1) return true; else return false; } //function to enter elements in queue void enqueue ( int value ) { //if queue is full if ((rear + 1)%SIZE == front) cout<<"Queue is full \n"; else { //now the first element is inserted if( front == -1) front = 0; //inserting element at rear end rear = (rear+1)%SIZE; A[rear] = value; } } //function to remove elements from queue void dequeue ( ) { if( isempty() ) cout<<"Queue is empty\n"; else //only one element if( front == rear ) front = rear = -1; else front = ( front + 1)%SIZE; } //function to show the element at front void showfront() { if( isempty()) cout<<"Queue is empty\n"; else cout<<"element at front is:"<<A[front]; } //function to display the queue void…arrow_forward*Please using JAVA only* Objective Program 3: Binary Search Tree Program The primary objective of this program is to learn to implement binary search trees and to combine their functionalities with linked lists. Program Description In a multiplayer game, players' avatars are placed in a large game scene, and each avatar has its information in the game. Write a program to manage players' information in a multiplayer game using a Binary Search (BS) tree for a multiplayer game. A node in the BS tree represents each player. Each player should have an ID number, avatar name, and stamina level. The players will be arranged in the BS tree based on their ID numbers. If there is only one player in the game scene, it is represented by one node (root) in the tree. Once another player enters the game scene, a new node will be created and inserted in the BS tree based on the player ID number. Players during the gameplay will receive hits that reduce their stamina. If the players lose…arrow_forwardUsing c++ Contact list: Binary Search A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Define and call the following function. The return value of FindContact is the index of the contact with the provided contact name. If the name is not found, the function should return -1 This function should use binary search. Modify the algorithm to output the count of how many comparisons using == with the contactName were performed during the search, before it returns the index (or -1). int FindContact(ContactInfo contacts[], int size, string contactName) Ex: If the input is: 3 Frank 867-5309 Joe…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education