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
What are the pros and cons of using ICT​
Setler79 [48]

Answer:

Communication - Speed / time – money can be saved because it's much quicker to move information around. ...

Globalization - Video conferencing saves money on flights and accommodation. ...

Cost effectiveness - It feels free to send an email (although it isn't); it's without doubt cheaper than phone calls.

Explanation:

4 0
2 years ago
Which device or appliance emits radio waves
ale4655 [162]
There are multiple devices that emit radio waves. The most obvious is are radiod and microwaves (yes, the food cooker). Wireless applicances also emit radio waves. But don't confuse everything to use microwaves. Some applicances use frequencies instead of radio waves. Some applicances that use frequencies are toy control remotes and a garage door.

I hope this helps! Please make sure ask me if you need more clarity!
8 0
2 years ago
2. Create a file with the follow integer/string content and save it as fun.txt. 6 fun. 3 hello 10 &lt;&gt; 2 25 4 wow! Write an
Nesterboy [21]

Answer:

see explaination

Explanation:

I made use of python program to solve this.

text file name with fun.txt.

6 fun. 3 hello 10 <> 2 25 4 wow!

Program code:

import re

file = open('fun.txt','r') #for reading file

strings="" #declaring empty string

for k in file:

strings=strings+k #all character in file is storing in strings variable for do operations

pattern = '\s' #for pattern \s is for space

result = re.split(pattern, strings) #split the string with space

for k in range(len(result)): #loop through the list of string

if(k%2) == 0: #checking for integer to time of string

p=int(result[k])

print(result[k+1] *p) #print times of the string(k+1)

Check attachment for output

8 0
2 years ago
You have a number of digital pictures you recently took on your smartphone. You would like to share these pictures with all of y
wlad13 [49]

a cloud phone system is a Voice over IP (VoIP) based business telephoneplatform that is hosted by a third-party provider such as OnSIP. Cloud phonesystems typically offer advanced security and telephony features such as: extension dialing, auto attendants, and conference bridges

7 0
3 years ago
Read 2 more answers
C++ a. Write a program that uses the function isPalindrome given in example 6-6 (Palindrome). Test your program on the followinn
Whitepunk [10]

Answer:

#include <iostream>

#include <array>

using namespace std;

bool isPalindrome(string str)  

{  

int length = str.length();  

for (int i = 0; i < length / 2; i++)  

 if (toupper(str[i]) != toupper(str[length - 1 - i]))

  return false;  

return true;  

}

int main()

{

array<string, 6> tests = { "madam", "abba", "22", "67876", "444244", "trymEuemYRT" };

for (auto test : tests) {

 cout << test << " is " << (isPalindrome(test) ? "" : "NOT ") << "a palindrome.\n";

}

}

Explanation:

The toupper() addition forces characters to uppercase, thereby making the comparison case insensitive.

5 0
3 years ago
Other questions:
  • A(n) ________ file contains data that has been encoded as text, using one of the computer's encoding schemes.
    14·2 answers
  • Fundamental types of data, such as strings, integers, and real numbers, are known as
    5·1 answer
  • How does scarcity affect what gets produced
    5·1 answer
  • Conduct online research to determine specific conflict-resolution and management techniques and skills that would be beneficial
    5·1 answer
  • Who share the road with an impaired driver are at risk
    7·2 answers
  • Mary is entering her senior year of college. She has a meeting on Friday with her advisor to discuss her career plans.Mary is al
    15·1 answer
  • Which phrase is a comparison operator for inserting a not equal to argument in an IF, COUNTIF or SUMIF function? &lt;= &lt;&gt;
    9·1 answer
  • One gigabyte can be expressed as: a.) 1,000 kilobytes b.) 1,000 bytes c.) 80,000 kilobytes d.) 1,000 megabytes e.) 8,000 bits
    5·1 answer
  • Which of the following statements is true of a time management plan? It is work in progress that need to be altered many times?
    10·1 answer
  • WHO WANT P O I N T S.................................................
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!