2S2122 Activity 1.2

From Microlab Classes
Revision as of 18:08, 5 February 2022 by Ryan Antonio (talk | contribs) (Created page with "== Instructions == * For our programming exercises, we will use [https://colab.research.google.com/ Google Colab]. ** If you are familiar with Jupyter Notbook then you probabl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Instructions

  • For our programming exercises, we will use Google Colab.
    • If you are familiar with Jupyter Notbook then you probably would know how to use Google Colab.
    • It's an open source mark down language with Python support. Almost exactly like Jupyter.
    • Discovering how to use Google Colab is part of your homework. Go ahead and tinker with it.
  • Submission guidelines are as follows:
    • For every programming exercise, you are to submit your .ipynb file into your respective submission bin.
    • To download your .ipynb file, first in your Google Colab page go to File > Download > Download .ipynb file.
    • Don't forget to rename your .ipynb file with the following format "class_lastname_firstname_studentnumber.ipynb".

Programming Problem

Your main task is to create a bubble sort function that takes in some list as input and prints each row iteration until we reach the final sorted list. You need to sort the input list in ascending order. The .ipynb that you will use is in our UVLE page. Please find it there. A few things that we want for our program:

  • The sorting must be in ascending order.
  • It only takes in an input list (we prepared this for you already).
  • Use function recursions. Go research what this means.
  • Don't forget to put in your student number fir the function that generates a random list. We'll use your student number as a seed for the random number generator.

Some Details About the Activity

You only need to fill in the contents of the bubble sort function. Particularly on:

def bubble_sort(list_to_sort):
  #Insert nice code in here

There is a pre-made function that generates a random list. Strictly don't change anything in this function. However, in the set-up portion, please change the input to your student number. The pre-made function is:

def gen_random_list(sn):
  random.seed(sn)
  rand_list = []

  for i in range(8):
    temp_rand = random.randint(0,100)

    while(temp_rand in rand_list):
      temp_rand = random.randint(0,100)

    rand_list.append(temp_rand)

  return rand_list


Grading Rubrics

  • If your program works AND you used function recursions, you get 10 full points.
    • You can use at most 1 for loop for this case.
  • If your program works BUT you did not use function recursions, you only get 8 points.
    • This is when you use 2 or more for loops.
    • For loops have high complexity, that's why we try to use recursions instead.
  • No submission or the code doesn't work is automatically 0 points.