@zareen
Throughout history, both small and large nations have elevated certain types of nonelected workers to positions of relative power within the governmental structure. Collectively, these essential workers are called the bureaucracy. A bureaucracy is an administrative group of nonelected officials charged with carrying out functions connected to a series of policies and programs. In the United States, the bureaucracy began as a very small collection of individuals. Over time, however, it grew to be a major force in political affairs. Indeed, it grew so large that politicians in modern times have ridiculed it to great political advantage. However, the country’s many bureaucrats or civil servants, the individuals who work in the bureaucracy, fill necessary and even instrumental roles in every area of government: from highlevel positions in foreign affairs and intelligence collection agencies to clerks and staff in the smallest regulatory agencies. They are hired, or sometimes appointed, for their expertise in carrying out the functions and programs of the government.
link text
CS502 Assignment No. 01 Solution and Discussion

Assignment No. 01 SEMESTER Fall 2019
CS502 Fundamentals of Algorithms
Total Marks: 20Due Date: 13/11/2019
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit if:
• The assignment is submitted after due date.
• The submitted assignment does not open or file corrupt.
• The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
• Student ID is not mentioned in the assignment File or name of file is other than student ID.
• The assignment is not submitted in .doc or .docx format.
Uploading instructions
Your submission must include:• Assignment should be in .doc or .docx format.
• Save your assignment with your ID (e.g. bx180200786.doc).
Assignment submission through email is NOT acceptable
Objective
The objective of this assignment is
• To give basic knowledge and understanding of Algorithms.
• To be able to design simple algorithms.
• To be able to understand and calculate the complexity of algorithms.Note:
Your answer must follow the below given specifications.
• Font style: “Times New Roman”
• Font color: “Black”
• Font size: “12”
• Bold for heading only.
• Font in Italic is not allowed at all.
• No formatting or bullets are allowed to use.
• Your answer should be precise and to the point, avoid irrelevant detail.Lectures Covered: This assignment covers Lecture # 01  06
Deadline
Your assignment must be uploaded/submitted at or before 13/11/2019.Assignment Statement:
In mathematics Prime is a number which can be only divisible by 1 and itself. Examples of prime numbers are, 1 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 etc. When these numbers get large, then it is very difficult to manually identify them as to be prime or not prime. For example the numbers like, 443 and 44371 cannot easily identify as Prime.
There may be many algorithms which can be written for the identification of a number to be prime or not prime.Question No 01: (Marks: 10)
You are required to design (write) a simple algorithm (Only Pseudo code) which can identify a number to be Prime or Not Prime.Question No 02: (Marks: 10)
You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 01.=====================================Ended=======================================
For any query about the assignment, contact at [email protected]
GOOD LUCK

@zareen said in CS502 Assignment No. 01 Solution and Discussion:
Question No 02: (Marks: 10)
You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 01.Solution:
Question No. 02: The step by stem analysis of the algorithm designed in question 1 is as follow,The time taken by each statement (step) is given as follows,
Step 1: C1 // Execute only 1 time or Constant Time or O (1)
Step 2: C2 // Execute only 1 time or Constant Time or O (1)
Step 3: n 2 // Execute n 2 times
Step 4: n 2 // Execute n 2 times
Step 5: n – 2 // Execute n 2 times
Step 6: C3 // Execute only 1 time or Constant Time or O (1)
Step 7: C4 // Execute only 1 time or Constant Time or O (1)
Step 8: C5 // Execute only 1 time or Constant Time or O (1)
Step 9: C6 // Execute only 1 time or Constant Time or O (1)Total time T(n) can be calculated as follows,
T(n) = C1 + C2 + (n 2 ) + (n 2 ) + (n 2 ) + C3 + C4 + C5 + C6
T(n) = C1 + C2 + n 2 + n 2 + n 2 + C3 + C4 + C5 + C6
T(n) = C1 + C2 + n + n + n  6 + C3 + C4 + C5 + C6
T(n) = 3n + C1 + C2 + C3 + C4 + C5 + C6 6
T(n) = 3n + (C1 + C2 + C3 + C4 + C5 + C6 6)
T(n) = 3n + C7 // C7 = (C1 + C2 + C3 + C4 + C5 + C6 6)
T(n) = n // Ignoring constant termsOr T(n) = O (n )

@zareen said in CS502 Assignment No. 01 Solution and Discussion:
Question No 01: (Marks: 10)
You are required to design (write) a simple algorithm (Only Pseudo code) which can identify a number to be Prime or Not Prime.Solution:
Question No. 01: The algorithm for the identification of Prime number is as follows,1 PRIME (int Number)
2 int Count ← 0
3 for i ← 2 to Number – 1
4 if ( Number % i equal to 0)
5 Increment Count
6 If (Count is equal to 0)
7 Number is Prime
8 else
9 Number is NOT Prime

Question No. 02: The step by stem analysis of the algorithm designed in question 1 is as follow,
The time taken by each statement (step) is given as follows,
Step 1: C1 // Execute only 1 time or Constant Time or O (1)
Step 2: C2 // Execute only 1 time or Constant Time or O (1)
Step 3: n 2 // Execute n 2 times
Step 4: n 2 // Execute n 2 times
Step 5: n – 2 // Execute n 2 times
Step 6: C3 // Execute only 1 time or Constant Time or O (1)
Step 7: C4 // Execute only 1 time or Constant Time or O (1)
Step 8: C5 // Execute only 1 time or Constant Time or O (1)
Step 9: C6 // Execute only 1 time or Constant Time or O (1)Total time T(n) can be calculated as follows,
T(n) = C1 + C2 + (n 2 ) + (n 2 ) + (n 2 ) + C3 + C4 + C5 + C6
T(n) = C1 + C2 + n 2 + n 2 + n 2 + C3 + C4 + C5 + C6
T(n) = C1 + C2 + n + n + n  6 + C3 + C4 + C5 + C6
T(n) = 3n + C1 + C2 + C3 + C4 + C5 + C6 6
T(n) = 3n + (C1 + C2 + C3 + C4 + C5 + C6 6)
T(n) = 3n + C7 // C7 = (C1 + C2 + C3 + C4 + C5 + C6 6)
T(n) = n // Ignoring constant termsOr T(n) = O (n )

Solution:
Question No. 01: The algorithm for the identification of Prime number is as follows,1 PRIME (int Number)
2 int Count ← 0
3 for i ← 2 to Number – 1
4 if ( Number % i equal to 0)
5 Increment Count
6 If (Count is equal to 0)
7 Number is Prime
8 else
9 Number is NOT Prime




Recent Topics

SOLVED CS432 Assignment 2 Solution and Discussion
CS432  Network Modeling and Simulation10 
SOLVED CS605 Assignment 2 Solution and Discussion
CS605  Software EngineeringII8 
UNSOLVED MTH404 Assignment 2 Solution and Discussion
MTH404  Dynamics5 
org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression
Android Development4 
STAT408 Assignment 1 Solution and Discussion
STAT408  Experimental Design Analysis4 
SOLVED MTH304 Assignment 2 Solution and Discussion
MTH304  Statics4 
SOLVED CS432 Assignment 1 Solution and Discussion
CS432  Network Modeling and Simulation4 
SOLVED CS703 Assignment 2 Solution and Discussion
CS703  Advanced Operating Systems4 
SOLVED CS625 Assignment 2 Solution and Discussion
CS625  Professional Practices4 
SOLVED MGT713 GDB 1 Solution and Discussion
MGT713  Production / Operations Management3 
SOLVED FIN725 GDB 1 Solution and Discussion
FIN725  Credit & Risk Management3 
SOLVED EDU508 Assignment 1 Solution and Discussion
EDU508  Teaching of English Language3 
SOLVED BNK611 Quiz 2 Solution and Discussion
BNK611  Economic Ideology in Islam3 
SOLVED ACC311 Quiz 2 Solution and Discussion
ACC311 Fundamentals of Auditing3 
SOLVED CS001 Assignment 2 Solution and Discussion
CS001 Computer Proficiency License3 
SOLVED MTH633 Assignment 1 Solution and Discussion
MTH633  Group Theory3 
SOLVED BNK603 Assignment 1 Solution and Discussion
BNK603  Consumer Banking2 
SOLVED CS406 Assignment 2 Solution and Discussion
CS406  Web Based Database Applications2 
SOLVED CS510 Assignment 1 Solution and Discussion
CS510  Software Requirements and Specifications2 
SOLVED CS510 Assignment 2 Solution and Discussion
CS510  Software Requirements and Specifications2