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
nikklg [1K]
3 years ago
9

If we compare the push function of the stack with the insertFirst function for general lists, we see that the algorithms to impl

ement these operations are similar.
True

False
Computers and Technology
1 answer:
Jet001 [13]3 years ago
8 0

Answer:

True

Explanation:

<u>Algorithm for push function</u>

The method of placing data on a stack is called a push operation.

It involves these steps −

  • Check that the stack is complete.  
  • If the stack is complete, it will cause an error .  
  • Increases top to point next empty room if the stack is not complete.  
  • Adds the data component to the place of the stack where top is pointing.
  • Success returns.

<u>Algorithm for Insertfirst function</u>

  • Create a new Link with provided data.
  • Point New Link to old First Link.
  • Point First Link to this New Link.

As we can see that in both algorithms ,we are inserting data to a new nodes and incrementing/pointing to a new node for inserting data.Both algorithms uses the same approach.

You might be interested in
JAVA Question!
dybincka [34]
I don't see any error on your code, everything is well written and simple. Except trying putting PUBLIC on your Class displayer. If you encounter the same problem again try to rebuild your whole code and try to recompile the whole code. Even try restarting your personal computer.
5 0
3 years ago
Write a Java program in jGRASP that creates a 2D integer array of 5 rows and 20 columns, fills it with increasing integer values
Alex73 [517]

Answer:

As per the question we need to make 5 rowa and 2o columns, in this we have total element 100 so range should be 0 to 99, but we are suggested to keep range 0 to 59, so i have kept the elementns in the range, but if it was a typo in the question for range you do not need to reset the k with zero.

Explanation:

//create a new class  TestArray

public class TestArray {

//define main method

public static void main(String[] args) {

 //declare a 2D array of given size i.e. 5 rows and 20 columns

 int arr[][] = new int[5][20];

 //declare an integer variable k and initialize it with zero, this will used to initialize the array from 0 to 99

 int k = 0;

 //for loop for rows

 for (int i = 0; i < 5; i++) {

  //for loop for columns

  for (int j = 0; j < 20; j++) {

   //initialize arr with the current value of k

   arr[i][j] = k;

   //once k is 59 set it zero again as we are not going beyond 59

   if(k == 59)

    k = 0;

   //increment value of k with 1

   k++;

  }

 }

 //print the element from the array one by one

 //for loop for rows

 for (int i = 0; i < 5; i++) {

  //for loop for columns

  for (int j = 0; j < 20; j++) {

   //print the current element of array and an space with it

   System.out.print(arr[i][j]+" ");

  }

  // move the cursor to new line

  System.out.println();

 }

}

}

7 0
3 years ago
PLEASE HELP 15 POINTS Emma plans on building a dog house using an algorithm. What will be the final step of the process? a) crea
cupoosta [38]

Answer:

Most likely C

Explanation:

Blueprint is the plan so she makes it 1st.

Building the roof is after the deck.

The deck is after the blueprint.

After it's all done she looks at it and thinks about what went wrong at then end.

If there are no mistakes it's B.

Hope this answers your question :).

6 0
2 years ago
Write a loop that reads strings from standard input where the string is either "land", "air", or "water". The loop terminates wh
Setler79 [48]

The loop terminates when "xxxxx" is read in. If the word is land, the string followed by "land" get outputted. The same with air, and water.

Explanation:

int land = 0;

int air = 0;

int water = 0;

String word = "";

while(!(word.equals("xxxxx"))) {

word = stdin.next();

if(word.equals("land")) {

   land++;

}else if(word.equals("air")) {

   air++;

}else if(word.equals("water")) {

   water++;

}  

}

System.out.println("land:" + land);

System.out.println("air:" + air);

System.out.println("water:" + water);

5 0
3 years ago
This function returns the length of a string:
Anna71 [15]

Answer:

The strlen() function calculates the length of a given string.The strlen() function is defined in string.h header file.

Explanation:

It doesn’t count null character ‘0’. Syntax: int strlen(const char *str); Parameter: str: It represents the string variable whose length we have to find. Return: This function returns the length of string passed.

4 0
1 year ago
Other questions:
  • Which markup language would be considered the most current for web design? HTLM, HTML5, XHTLM, XHTML 6
    14·2 answers
  • The n modifier after the tilde forces the index variable to expand only to the ______
    15·1 answer
  • 3. You are a network administrator responsible for all network platforms and services. The Teta Company currently has only one b
    13·2 answers
  • If one breakfast meal of banana lacatan, scrambled egg, plain rice, and hot milk contains 58 grams carbohydrate, 12 grams protei
    11·1 answer
  • ‘The increased availability of mobile digital devices has had a positive impact on how young people use their free time’. Make a
    8·1 answer
  • What is the simplest way to permanantly get rid of an unwanted file
    14·1 answer
  • What type of photography is represented by a photograph of a dog on a beach ?
    11·1 answer
  • The term packet is used fairly generically to refer to protocol data unit (PDU). There are PDU equivalent names in the different
    15·1 answer
  • The first person to say something in here will get brainliested.
    7·2 answers
  • The direction of a ratchet is reversed by _______________________.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!