Launching into Computer Science

An Introduction to Algorithms and Basic Programming Concepts

Unit 8

This Unit provides essential materials for algorithms. An algorithm is used to solve the user's problems by defining a problem so that the computer can understand it. The computer reads the problem as an instruction (input of the user) and follows it step by step until the problem is solved and an output is produced. Therefore, it needs to define relationships between the set of inputs, computational process and the input and requested output. Furthermore, it is vital how a problem is defined; a good algorithm needs to be efficient and straightforward. Thus it is helpful to know different-solving steps. For describing a problem, an algorithm can contain if-then-else or loops like 'while' or 'for' commands and different mathematical operators such as addition (+) or subtraction (-). Moreover, since there are many programming languages and people who want to understand the algorithm, a programmer has to know to describe an algorithm in a human-friendly language. For example, an algorithm can easily be translated into other languages with pseudocode or flow-chart.

Outcomes

  • Summary of the learning outcomes

This unit aims to:

  • Apply the algorithm framework for describing and solving a problem
  • Demonstrate a step by step approach to solving a problem using pseudocode
  • Validate the output using different quality assurance matrices
  • Artefacts

    The projects of the unit to achieve those learning outcomes:

    Python Programming: Data Sort Using Cards
  • Data Sort Using Cards
  • Github: Sorting Cards Project
  • #insert a random card in a list of sorted card
    import random 
    														
    card_list = [10, 6, 5, 3, 2] #array of sorted card right to left
    second_card_list = [] #second array for searching cards > random card
    														
    #Step 1: pick a random card between 0 - 15
    rand_num = random.randint(0,15) 
    print(rand_num)
    														
    #Step 2: search numbers which is > rand_num by creating a second_ array (second_card_list)
    index = 0
    for i in range (0, len(card_list)): 
    	if card_list[i] > rand_num:
    		second_card_list.append(card_list[i])
    		index += 1
    print(second_card_list)
    														
    #Step 3: last element of second_card_list is adjacent number of rand_num, searching index of adjacent number in card_list
    count = 0
    while count < len(card_list):  
    	if not second_card_list:
    		sequence_number = 0
    		print(second_card_list)
    		break
    	elif card_list[count] == second_card_list[-1]:
    		sequence_number = count
    		break
    	else: 
    		count += 1
    print(sequence_number)
    														
    #Step 4: Insert rand_num in array (array_c)
    if not second_card_list: 
    	card_list.insert(sequence_number, rand_num)
    else:
    	card_list.insert(sequence_number +1, rand_num)
    														
    														
    #Step 5: print the sorted array with the random card
    print(card_list)
    

    Assignment Part 1: Data Structures and Algorithm Design
  • Data Structures and Algorithm Design - Contact Book
  • Reflection

What exactly have I learnt and how?

I completed the entire Python course, and I have learned how to write an algorithm and how to solve a problem. I am pretty proud of myself that I can program now. However, it is the beginning of my learning process, and I am motivated to learn more about how to code and solve problems. Furthermore, the assignment gives me a better understanding of using data structures and functions in python.
  • Notes

Notes from the elaboration of the unit, various meetings, and feedback from team members and tutors

Here are few insights from the last "Python" courses:

Contact Me