Purchase Solution

Analyze Pseudocode

Not what you're looking for?

The following are a few examples of pseudocode:

>> Example 1

start

if Quantity > 100 then

Discount = 20

else

if Quantity > 12 then

Discount = 10

endif

endif

Total = Price* Quantity
Total = Total - (Discount* Total)/100
Print Total

Stop

>> Example 2

Start

Pass = 0
Fail = 0
Total = 0
X = 0
while (End Of Student_Marks_File) do

Total = Total + Subject_Marks

if (Subject_Marks > 40) then

Print "Student passed in" Subject

else

Print "Student failed in" Subject

endif
X = X +1

endwhile
Average = Total/X
Print "Average Marks of" Student_Name "are" Average

Stop

From the above examples of pseudocode containing control structures, analyze the logic implemented in the pseudocode.

Solution Summary

The solution analyzes pseudocodes.

Solution Preview

First, some basic definition taken from http://www.cs.cornell.edu/Courses/cs482/2003su/handouts/pseudocode.pdf

"Algorithms will often be expressed in pseudocode, a mixture of code and English ... Pseudocode strikes a sometimes precarious balance between the understandability and informality of English and the precision of code."

(it's worth reading the whole PDF by the way).

Keep in mind that unlike a programming language where there's a defined syntax, no 'standard' way exists in writing pseudocode. The key point to keep in mind when writing one is clarity and readability while being able to convey the essence of the algorithm outlined.

That said, the following is the analysis of pseudocode in example 1:

1. (Stating the obvious) It can be seen that a pseudocode block is enclosed within the start and stop commands.
2. The next block of the algorithm

performs reading of some "Customer_Order_Record" from somewhere. Notice here that the pseudocode is kept high-level and does not specify the exact mechanism of how to perform this reading and from where. The input could be read, for instance, from some IO stream off the disk or input typed by the user from the console or some data streamed from the network. The specific details are left out for implementation.

3. The next conditional statement

if Quantity > 100 then

Discount = 20 ...

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Basic Networking Questions

This quiz consists of some basic networking questions.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://brainmass.com/computer-science/pseudocode/analyze-pseudocode-457633", "fetch_time": 1716779260000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2024-22/segments/1715971059028.82/warc/CC-MAIN-20240527021852-20240527051852-00512.warc.gz", "warc_record_offset": 115942028, "warc_record_length": 7281, "token_count": 657, "char_count": 2961, "score": 3.546875, "int_score": 4, "crawl": "CC-MAIN-2024-22", "snapshot_type": "latest", "language": "en", "language_score": 0.8724637627601624, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00031-of-00064.parquet"}