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
You need to pay an Internet Service Provider (ISP) for services rendered. Which payment technology would you use?
-Dominant- [34]

Answer:

D. Electronic Funds Transfer (EFT)

Explanation:

e-commerce is a short for electronic commerce and it can be defined as a marketing strategy that deals with meeting the needs of consumers, by selling products or services to the consumers over the internet.

This ultimately implies that, e-commerce is strictly based on the buying and selling of goods or services electronically, over the internet or through a digital platform. Also, the payment for such goods or services are typically done over the internet such as online payment services.

A payment gateway can be defined as a merchant service technology used for the capturing, acceptance and transfer of digital payment from the bank account of a customer (buyer) to the bank account of the merchant (seller). Thus, payment gateway typically involves the use of credit or debit card for the payment of goods purchased or services provided.

In this scenario, you need to pay an Internet Service Provider (ISP) for services rendered. Thus, the payment technology which you would use is Electronic Funds Transfer (EFT).

3 0
2 years ago
Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string
Svetach [21]

Answer:

def length( mystring):

   count = 0

   for i in mystring:

       count += 1

   return count

def reversed( mystring):

   strlist = []

   for i in range(length(mystring)):

       strlist.append(mystring[(length(mystring) - 1) - i])

       txt = "".join(strlist)

   return txt

string = 'Yolanda'

print(reversed(string))

Explanation:

The python module defines two functions 'reversed' and 'length'. The length function counts the number of characters in a string variable while the reversed function reverses the string variable value.

3 0
2 years ago
1. It is acceptable to use a jack that has been
krok68 [10]
D. None of the above
7 0
2 years ago
How do you create multiple columns in Word?
mrs_skeptik [129]

Answer:

I think it's B

Explanation:

it sounded right to me.

7 0
3 years ago
Which interest bearing account is best for people who won’t need access to their money for several months or longer?
lutik1710 [3]

The correct answer to this question is a certificate of deposit.

A certificate of deposit is an interest bearing account that pays a higher rate of interest than a savings account or interest bearing checking account because you are committing to leave it in the bank for a specified period of time. The CD could be for serveral months, or extend out to multiple years. Normally the interest rate will increase as the length of time increases.

3 0
3 years ago
Other questions:
  • For any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. Ex: I
    8·1 answer
  • Which of the following is a Microsoft solution that runs on a Microsoft Terminal Services server but appears, to end users, as i
    10·1 answer
  • "The effectiveness of memory retrieval is directly related to the similarity of cues present when the memory was encoded to the
    11·1 answer
  • Using symbols (%, $, #, etc.) can make it easier to take notes.
    8·2 answers
  • What will be the values of ans, x, and y after the following statements are executed? int ans = 35, x = 50, y =50; if ( x &gt;=
    7·2 answers
  • What should be used to keep a tablet dry?
    13·1 answer
  • What is project scope? a. Quantifiable criteria that must be met for the project to be considered a success b. Products, service
    5·1 answer
  • Tech A says that gasoline vapors are lighter than air, so inspection pits do not have a fire hazard like above ground hoists. Te
    9·1 answer
  • Nathan has a 30-second clip of music that he wants to play over and over again when he runs a program. What does Nathan need to
    5·2 answers
  • HELP PLEASE
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!