1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nimfa-mama [501]
3 years ago
6

In your own words, describe the structure and function of both the stack and queue data structure and discuss how they are diffe

rent from the perspective of how they are used.
Computers and Technology
1 answer:
Kobotan [32]3 years ago
6 0

Answer:

Following are the answer to this question:

Explanation:

Stack:

The stack data structure is used to create method, parsing, analysis of expression, and tracking. This data type uses the LIFO system, which stands from the Last In First Out. This data structure operates on the top side. In this data structure, it performs two methods, that are "push() and pop()" method and the time complexity of the stack data structure O(1).

Example of Stack:

import java.util.*;//import package

 public class Main //defining class Main

{      

public static void main (String[] ag)//defining main method  

  {

     ArrayDeque<Character> stack = new ArrayDeque<Character>();//creating Character array ArrayDeque  

       stack.push('A'); //add value in stack  

      stack.push('B');//add value in stack  

      stack.push('B'); //add value in stack  

      System.out.println("First Insert:"+stack); //print value         stack.pop();//remove value from stack    

    System.out.println("After removing element: "+stack); //print value         stack.push('B'); //add value in stack    

    stack.pop();//remove value from stack      

 System.out.println("final value: "+stack); //print value    

}

}

Output:

First Insert:[B, B, A]

After removing element: [B, A]

final value: [B, A]

Queue:

The queue data structure is an abstract type, it is similar to the stacks data structure. It is open at both ends when opposed to lines. It follows the FIFO method, which stands for the First-In-First-Out method, At one end data is inserted and at the other end, it deletes the data and the time complexity of the queue data structure O(1).

Example of Queue:

import java.util.*;//import package  

public class Main//defining a class queue

{  

    public static void main(String[] ars)//defining main method

    {  

      LinkedList<Integer> que= new LinkedList<Integer>();//defining integer array LinkedList    

      for (int i = 0; i < 5; i++)//defining fo loop to add value in queue  

     {    

        que.add(i); //use add method to insert value        

}        

System.out.println("Queue value: "+ que); //print queue value      

  int remove= que.remove(); //remove value from the queue          System.out.println("after removing value from queue: "+ remove);//removing element from queue  

      System.out.println(que);  //after removing the element print value  

  }

}  

Output:

Queue value: [0, 1, 2, 3, 4]

after removing value from queue: 0

[1, 2, 3, 4]

You might be interested in
Write the definitions for three function named max. Each receives two parameters, of the same type, and returns the larger of th
GenaCL600 [577]

Answer:

The method definition to this question can be given as:

Method definition:

double max(double x, double y)  //define method with double parameter  

{

if (x>=y)    //check condition.

return x;  //return value

else

return y;     //return value

}

double max(int x, int y)    //define method with integer parameter

{

if (x>=y)    //check condition

return x;    //return value

else

return y;  //return value

}

double max(char x, char y)   //define method with char parameter

{

if (x>=y)    //check condition

return x;    //return value

else

return y;    //return value

}

Explanation:

The above method definition can be described as below:

  • In the first method definition first, we define a method that is "max()". In this method we pass two variables as a parameter that is "x and y" and the datatype of this is double. Then we use a conditional statement. In the if block we check if variable x is greater then equal to y then it will return x else it will return y.  
  • In the second method definition, we define a method that is same as the first method name but in this method, we pass two integer variable that is "x and y". Then we use a conditional statement. In the if block we check if variable x is greater then equal to y then it will return x else it will return y.
  • In the third method definition, we define a method that is same as the first and second method name but in this method, we pass two char variable that is "x and y". Then we use a conditional statement. In the if block we check if variable x is greater then equal to y then it will return x else it will return y.
8 0
3 years ago
Suppose that a machine with a 5-stage pipeline uses branch prediction. 15% of the instructions for a given test program are bran
zhenek [66]

Answer:

solution attached below

Explanation:

3 0
3 years ago
If wire rope guard rails are used what must also be done?
zzz [600]
A Deceleration device.
A rope, wire rope, or strap with connectors at each end for connecting the 5 point body harness to a lifeline, or anchorage.

Look under OSHA Flashcards on Quizlet and..
OSHA: Fall Protection in Construction, Subpart M and just past that area in the document.

This is from that document on page 13 and 14:  
Fall Restraint Systems:  While fall restraint systems are not mentioned in Subpart M, OSHA recognizes a fall restraint system as a means of prevention. The system, if properly used, tethers a worker in a manner that will not allow a fall of any distance. This system is comprised of a body belt or body harness, an anchorage, connectors, and other necessary equipment. Other components typically include Photo: Skip Pennington OCCUPATIONAL SAFETY AND HEALTH ADMINISTRATION 1 4 a lanyard, a lifeline, and other devices. For a restraint system to work, the anchorage must be strong enough to prevent the worker from moving past the point where the system is fully extended, including an appropriate safety factor. *In a November 2, 1995 interpretation letter to Mr. Dennis Gilmore, OSHA suggested that, at a minimum, a fall restraint system must have the capacity to withstand at least 3,000 pounds or twice the maximum expected force that is needed to restrain the person from exposure to the fall hazard. In determining this force, consideration should be given to site-specific factors such as the force generated by a person (including his/her tools, equipment, and materials) walking, slipping, tripping, leaning, or sliding along the work surface.

8 0
3 years ago
All of the following are ways to improve the mobile experience for a website visitor EXCEPT:
Jobisdone [24]

Answer:

Adding more links to the page.

Explanation:

User experience design, UED, is a concept or a process of software development application life cycle that graphically presents a clients project to reflect the needs, want and interactivity of the users.

There are certain principles that governs the design of user interactive web and mobile interfaces. A user interface has to be simple, easy to interact with, give a good feel, signing into email, phone, laptop, mobile app etc, should also be made easy.

Covering the screen with link, makes it difficult to navigate without triggering a link.

3 0
3 years ago
Examples of ________, which is hosted on a web site, include e-mail, word processing, tax preparation, and game programs.
Keith_Richards [23]

Answer:Web Application

Explanation:Web hosting is more or less like having an ordinary computer in the cloud in order share information and resources with others world wide.One cannot make effective use of a computer without software applications . Similarly hosting just normal html pages and documents on a server cannot help increase productivity,hence the creation of cloud computer applications also known as "Web Apps (Web Applications)" to aid boost productivity and information dissemination via quality task automations.

4 0
2 years ago
Other questions:
  • Why does the hp computer not have Bluetooth?
    6·1 answer
  • Suppose you have two arrays of ints, arr1 and arr2, each containing ints that are sorted in ascending order. Write a static meth
    7·1 answer
  • Universal Containers is tracking the interviewer's ratings of candidate in Salesforce. They would like to easily link the Candid
    5·1 answer
  • Communications that take the form of electronic junk mail or unsolicited e-mail are referred to as
    13·2 answers
  • Please Help!! How to code this in Python?
    11·1 answer
  • Analyze the following code: class Test { public static void main(String[] args) { System.out.println(xMethod((double)5)); } publ
    7·1 answer
  • When a hoverboard's battery dies, does the hoverboard battery life get impacted the next time the battery is full?
    12·1 answer
  • Write the definition of a class Phone containing: 1. A data member named model of type string. 2. A data member named partNumber
    11·1 answer
  • True or False, In adversarial searching, agents using the MiniMax algorithm always select the state that has the highest guarant
    15·1 answer
  • Put simply, what tasks do algorithms help computers perform?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!