Question

help me answer the following questions please 1. Stack (LIFO) & its application 1. Stack overflow...

help me answer the following questions please

1. Stack (LIFO) & its application

1. Stack overflow & underflow

2. Implementation: partially filled array & linked list

3. Applications: reverse string, backtracking Exercises:

1) Which of the following applications may use a stack?

A. parentheses balancing program.

B. Keeping track of local variables at run time.

C. Syntax analyzer for a compiler.

D. All of the above.

2) Consider the usual algorithm for determining whether a sequence of parentheses is balanced. What is the maximum number of parentheses that will appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(())) ?

A. 1

B. 2

C. 3

D. 4

E. 5 or more

3) In the linked list implementation of the stack class, where does the push member function place the new entry on the linked list?

A. At the head

B. At the tail

C. After all other entries that are greater than the new entry.

D. After all other entries that are smaller than the new entry.

2. Queue (FIFO) & its application

1. Application: buffer data

2. Implementation: partially filled circular array & linked list

Exercises:

1) One difference between a queue and a stack is:

A. Queues require dynamic memory, but stacks do not.

B. Stacks require dynamic memory, but queues do not.

C. Queues use two ends of the structure; stacks use only one.

D. Stacks use two ends of the structure, queues use only one.

2) In the linked list implementation of the queue class, where does the push member function place the new entry on the linked list?

A. At the head

B. At the tail

C. After all other entries that are greater than the new entry.

D. After all other entries that are smaller than the new entry.

3) If data is a circular array of CAPACITY elements, and last is an index into that array, what is the formula for the index after last?

A. (last % 1) + CAPACITY

B. last % (1 + CAPACITY)

C. (last + 1) % CAPACITY

D. last + (1 % CAPACITY)

3. Recursion

1. Base case & recursive case

2. Infinite recursion

Exercises:

1) What is the importance of the stopping case in recursive functions?

2) Implement the following function. Do not use any local variables or loops.

void pattern(unsigned int n)

// Precondition: n > 0;

// Postcondition: The output consists of lines of integers.

The first line is the number n. The next line is the number 2n. The next line is the number 4n, and so on until y ou reach a number that is larger than 4242. This list of numbers is then repeated backward until you get back to n.

/* Example output with n = 840:

840

1680

3360

6720

6720

3360

1680

840

*/

3) Consider the following function:

void super_write_vertical(int number)

// Postcondition: The digits of the number have been written, stacked vertically. If number is negative, then a negative sign appears on top. Library facilities used: iostream.h, math.h

{

if (number < 0)

{

cout << '-' << endl; super_write_vertical(abs(number));

}

else if (number < 10)

cout << number << endl;

else

{

super_write_vertical(number/10);

cout << number % 10 << endl;

}

}

What values of number are directly handled by the stopping case?

A. number < 0

B. number < 10

C. number >= 0 && number < 10

D. number > 10

4) Consider this function declaration:

void quiz(int i)

{

if (i > 1)

{

quiz(i / 2);

quiz(i / 2);

} cout << "*";

}

How many asterisks are printed by the function call quiz(5)?

A. 3

B. 4

C. 7

D. 8

E. Some other number

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
help me answer the following questions please 1. Stack (LIFO) & its application 1. Stack overflow...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • HI USING C++ CAN YOU PLEASE PROGRAM THIS ASSIGNMENT AND ADD COMMENTS: stackARRAY: #include<iostream> #define SIZE...

    HI USING C++ CAN YOU PLEASE PROGRAM THIS ASSIGNMENT AND ADD COMMENTS: stackARRAY: #include<iostream> #define SIZE 100 #define NO_ELEMENT -999999 using namespace std; class Stack { int arr[SIZE]; // array to store Stack elements int top; public: Stack() { top = -1; } void push(int); // push an element into Stack int pop(); // pop the top element from Stack int topElement(); // get the top element void display(); // display Stack elements from top to bottom }; void Stack...

  • In C++ Implement a queue data structure using two stacks. Remember a queue has enqueue and...

    In C++ Implement a queue data structure using two stacks. Remember a queue has enqueue and dequeue functions. You could use either the array or linked list implementation for stacks and queues. Source for stack array: --------------------------------------------------- #include<iostream> #define SIZE 100 #define NO_ELEMENT -999999 using namespace std; class Stack { int arr[SIZE]; // array to store Stack elements int top; public: Stack() { top = -1; } void push(int); // push an element into Stack int pop(); // pop the...

  • (C++) Two stacks of the same type are the same if they have the same number...

    (C++) Two stacks of the same type are the same if they have the same number of elements and their elements at the corresponding positions are the same. Overload the relational operator == for the class stackType that returns true if two stacks of the same type are the same; it returns false otherwise. Also, write the definition of the function template to overload this operator. Write a program to test the various overloaded operators and functions of classstackType. **Please...

  • Can you please help with the below? 1)   Which of the following is true about using...

    Can you please help with the below? 1)   Which of the following is true about using a 2-3-4 tree? a.   It is designed to minimize node visits while keeping to an O(log n) search performance b.   It is designed to self-balance as new values are inserted into the tree c.   As soon as a node becomes full, it performs the split routine d.   None of the above 2)   Which of the following is true about a binary search tree? a.  ...

  • Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up...

    Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up for helping. True/False (13) Chapter 14 - A List Implementation that Links Data Adding a node to an empty chain is the same as adding a node to the beginning of a chain. Adding a node at the end of a chain of n nodes is the same as adding a node at position n. You need a temporary variable to reference nodes as...

  • Using C++ in Visual Studios Rewrite the code to use a Stack instead of a Queue....

    Using C++ in Visual Studios Rewrite the code to use a Stack instead of a Queue. You will need to think about the differences in the Stack and Queue. Think about how they operate and how the nodes may differ.   Modify the code as necessary. You will need to push to the Stack, pop from the Stack, peek at the Stack. You will need a member functions like in the example code. Your program will need to show that everything...

  • Please answer in C++. Derive a class called Stack from the linked list described in Assignment...

    Please answer in C++. Derive a class called Stack from the linked list described in Assignment 2 (list of Dates). This means the Stack class will inherit all the properties (data and functions) of the linked list. But, since a stack only allows pushing and popping at the front of the list only, you will need to prevent the operations at the back. To do this, derive the Stack class in such a way that the base class (LinkedList) functions...

  • Answer all questions 1- in circular singly linked list, previous pointer of the first node points...

    Answer all questions 1- in circular singly linked list, previous pointer of the first node points to which node A. First node B. Itself C. null D. Last node 2- Which of the following is NOT an applications of linked lists? A. Implementation of stacks and queues B. Dynamic memory allocation C. Manipulation of polynomials D. Keeping people at home during epidemics like corona virus 3- In a circular singly linked list? A. Components are all linked together in some...

  • help finish Queue, don't think I have the right thing. # 1. After studying the Stack...

    help finish Queue, don't think I have the right thing. # 1. After studying the Stack class and testStack() functions in stack.py # complete the Queue class below (and test it with the testQueue function) # # 2. Afer studying and testing the Circle class in circle.py, # complete the Rectangle class below (and test it with the testRectangle function) # # # 3. SUBMIT THIS ONE FILE, with your updates, TO ICON. # # # NOTE: you may certainly...

  • Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your...

    Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your own Array-Based Stack (ABS) and Array-Based Queue (ABQ). A stack is a linear data structure which follows the Last-In, First-Out (LIFO) property. LIFO means that the data most recently added is the first data to be removed. (Imagine a stack of books, or a stack of papers on a desk—the first one to be removed is the last one placed on top.) A queue...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT