Data Structures and Algorithms


Computer modeling is the process of creating an abstract model (including databases, data structures, and algorithms) to simulate the behavior and response of a real-world problem like air transportation system.

For example, a GCD (greatest common divisor) algorithm is given on the right side. Below is the system implemented by using Python, where the % operator is the modulo operation that returns the remainder of a division:
procedure GCD( int a, int b )
  repeat
    gcd = a mod b
    a = b
    b = gcd
  until a mod b == 0
  return gcd
end procedure

a =   b =    

           
~/public_html/cgi-bin/101/1/GCD.py (simplified)
#!/usr/bin/python
#
# Python code to demonstrate a naive method
#   GCD (greatest common divisor) using Euclidean algorithm
#

import cgi       # CGI module

form = cgi.FieldStorage( )     # Reads the HTML form data.
act  = form["act"].value
a    = form["a"  ].value
b    = form["b"  ].value

if ( act == "Find GCD( a, b )" ):
  # Print HTML.
  print( "Content-type: text/html\n\n" )
  # Command issued:
  print( "/usr/bin/python GCD.py " + a + " " + b )

  print( "GCD( " + a + ", " + b + " ) = " )
  a = int( a )
  b = int( b )
  while( b ):
    a, b = b, a % b
  print( abs( a ) )

Review: Computer Modeling
Computer modeling is the process of creating an abstract model to simulate the behavior of a real-world problem. Which is NOT included in an abstract model?
      Algorithm
      Data structure
      Database
      Operating system
Result: