Question

In: Computer Science

Looking for some more simple pseudocode (examples in bold italicized font below) for this chunk of...

Looking for some more simple pseudocode (examples in bold italicized font below) for this chunk of program? I have added some, but my professor prefers more than this, thank you and THUMBS UP always left for good answers!

---------------------------------------------------------------------------------------------------------------------------

       VectorStack<Integer> lowerValues = new VectorStack<Integer>();

       VectorStack<Integer> upperValues = new VectorStack<Integer>();

       for (int i = 0; i < data.length; i++)

       {

           lowerValues.push(data[i]);

       }
// While the lower values are not empty
       while (!lowerValues.isEmpty()) {

           temp = lowerValues.pop();

           while ((!upperValues.isEmpty() && temp < upperValues.peek()))

           {

               lowerValues.push(upperValues.pop());

// Push the pop of upper value

           }

           upperValues.push(temp);

       }

       while (!upperValues.isEmpty()) {

           for (int b = 0; b < data.length; b++) {

               result[b] = upperValues.pop();

               System.out.println(result[b]);

           }

       }

       return result;

   }

Solutions

Expert Solution

// Create a stack of integers to store the lower values

VectorStack<Integer> lowerValues = new VectorStack<Integer>();

// Create a stack of integers to store the upper values

VectorStack<Integer> upperValues = new VectorStack<Integer>();

// Iterate through the data array and push each element to the stack lowerValues stack   

for (int i = 0; i < data.length; i++)

{

           lowerValues.push(data[i]);

}
// Now iterate through the lowerValues array until it is empty
       while (!lowerValues.isEmpty()) {

// pop an element from lowerValues and store it in temp

           temp = lowerValues.pop();

// Now iterate through the upperValues stack until it is empty and the top element is greater then temp

           while ((!upperValues.isEmpty() && temp < upperValues.peek()))

           {

// pop an element from upperValues and push it to lowerValues

               lowerValues.push(upperValues.pop());

           }

// Now, push temp to upperValues stack

           upperValues.push(temp);

       }

// finally iterate through the upperValues stack until it is empty

       while (!upperValues.isEmpty()) {

// iterate through the data array

           for (int b = 0; b < data.length; b++) {

// pop the element from upperValue and store it in result[b]

               result[b] = upperValues.pop();

// print the value of result[b]

               System.out.println(result[b]);

           }

       }

// return result array

       return result;

   }


Related Solutions

Can I get some simple pseudocode (simple descriptions as exampled in top italicized line) added to...
Can I get some simple pseudocode (simple descriptions as exampled in top italicized line) added to this small section of Java code? Thumbs up always left for answers! ------------------------------------------------------------------------------------------------------- // Check to see if two bags are equals.    public boolean equals(LinkedBag<T> aBag) {        boolean result = false; // result of comparison of bags        if (this.numberOfEntries == aBag.numberOfEntries) {            if (numberOfEntries == 0) {                return true;           ...
Other than looking only at the EU and Turkey, what are some examples of complex interdependence...
Other than looking only at the EU and Turkey, what are some examples of complex interdependence at work? Why is complex interdependence so important in understanding today's world?
Try to make it as simple as you can. Please provide the answers with some examples...
Try to make it as simple as you can. Please provide the answers with some examples as fast as you can. 11-Which of the following do all domains in the same forest have in common? (Choose all that apply.) a) The same domain name    b) The same schema c) The same user accounts    d) The same global catalog   12-Which of the following is a valid reason for using multiple forests? a) Centralized management     b) Need for different schemas c) Easy...
Try to make it as simple as you can. Please provide the answers with some examples...
Try to make it as simple as you can. Please provide the answers with some examples as fast as you can. 6-What are the potential disadvantages of using a dynamic and static IP Address? 7-Explain the functionality of a global catalog in the Windows networking. 8-Explain the following terms: TCP/IP protocol, and what are two command-line utilities that can be used to check TCP/IP configuration and IP connectivity, respectively? 9-Explain: Which Windows Server utility provides a common interface for tools...
Try to make it as simple as you can. Please provide the answers with some examples...
Try to make it as simple as you can. Please provide the answers with some examples as fast as you can. 11-Which of the following do all domains in the same forest have in common? (Choose all that apply.) a) The same domain name    b) The same schema c) The same user accounts    d) The same global catalog   12-Which of the following is a valid reason for using multiple forests? a) Centralized management     b) Need for different schemas c) Easy...
Try to make it as simple as you can. Please provide the answers with some examples...
Try to make it as simple as you can. Please provide the answers with some examples as fast as you can. 11-Which of the following do all domains in the same forest have in common? (Choose all that apply.) a) The same domain name    b) The same schema c) The same user accounts    d) The same global catalog   12-Which of the following is a valid reason for using multiple forests? a) Centralized management     b) Need for different schemas c) Easy...
Try to make it as simple as you can. Please provide the answers with some examples...
Try to make it as simple as you can. Please provide the answers with some examples as fast as you can. 1-The technology that make up the core functionality of Windows Server 2012 include Active Directory, the Microsoft Server Manager, DHCP and IIS. Explain, in your own words, the nature and function of these technologies. Answer: 2-Windows Server Core is a new installation option in Standard, Enterprise, and Datacenter editions. The traditional Windows GUI is not available in Server Core....
Try to make it as simple as you can. Please provide the answers with some examples...
Try to make it as simple as you can. Please provide the answers with some examples as fast as you can. 1-The technology that make up the core functionality of Windows Server 2012 include Active Directory, the Microsoft Server Manager, DHCP and IIS. Explain, in your own words, the nature and function of these technologies. Answer: 2-Windows Server Core is a new installation option in Standard, Enterprise, and Datacenter editions. The traditional Windows GUI is not available in Server Core....
Try to make it as simple as you can. Please provide the answers with some examples...
Try to make it as simple as you can. Please provide the answers with some examples as fast as you can. 6-What are the potential disadvantages of using a dynamic and static IP Address? 7-Explain the functionality of a global catalog in the Windows networking. 8-Explain the following terms: TCP/IP protocol, and what are two command-line utilities that can be used to check TCP/IP configuration and IP connectivity, respectively? 9-Explain: Which Windows Server utility provides a common interface for tools...
Try to make it as simple as you can. Please provide the answers with some examples...
Try to make it as simple as you can. Please provide the answers with some examples as fast as you can. 1-Which of the following best defines a computer used as a server? a)Computer hardware that includes fast disk drives and a lot of memory b)Operating system software that includes clients, such as a Web browser and Client for Microsoft Networks c)Operating system software that includes directory services and domain name services d)A computer with Linux installed. 2-If you want...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT