<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CS502 Assignment No. 01 Solution and Discussion]]></title><description><![CDATA[<p dir="auto">Assignment No. 01 SEMESTER Fall 2019<br />
CS502- Fundamentals of Algorithms	<br />
Total Marks: 20</p>
<p dir="auto">Due Date: 13/11/2019<br />
Instructions<br />
Please read the following instructions carefully before solving &amp; submitting assignment:<br />
It should be clear that your assignment will not get any credit  if:<br />
•	The assignment is submitted after due date.<br />
•	The submitted assignment does not open or file corrupt.<br />
•	The assignment is full or partially copied from (other student or ditto copy from handouts or internet).<br />
•	Student ID is not mentioned in the assignment File or name of file is other than student ID.<br />
•	The assignment is not submitted in .doc or .docx format.<br />
Uploading instructions<br />
Your submission must include:</p>
<p dir="auto">•	Assignment should be in .doc or .docx format.<br />
•	Save your assignment with your ID (e.g. bx180200786.doc).<br />
Assignment submission through email is NOT acceptable<br />
Objective<br />
The objective of this assignment is<br />
•	To give basic knowledge and understanding of Algorithms.<br />
•	To be able to design simple algorithms.<br />
•	To be able to understand and calculate the complexity of algorithms.</p>
<p dir="auto">Note:<br />
Your answer must follow the below given specifications.<br />
•	 Font style: “Times New Roman”<br />
•	 Font color: “Black”<br />
•	 Font size: “12”<br />
•	 Bold for heading only.<br />
•	 Font in Italic is not allowed at all.<br />
•	 No formatting or bullets are allowed to use.<br />
•	Your answer should be precise and to the point, avoid irrelevant detail.</p>
<p dir="auto">Lectures Covered: This assignment covers Lecture # 01 - 06<br />
Deadline<br />
Your assignment must be uploaded/submitted at or before 13/11/2019.</p>
<p dir="auto">Assignment Statement:</p>
<p dir="auto">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.<br />
There may be many algorithms which can be written for the identification of a number to be prime or not prime.</p>
<p dir="auto">Question No  01:   (Marks:  10)<br />
You are required to design (write) a simple algorithm (Only Pseudo code) which can identify a number to be Prime or Not Prime.</p>
<p dir="auto">Question No  02:   (Marks:  10)<br />
You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 01.</p>
<p dir="auto">=====================================Ended=======================================</p>
<p dir="auto">For any query about the assignment, contact at <a href="mailto:CS502@vu.edu.pk" target="_blank" rel="noopener noreferrer nofollow ugc">CS502@vu.edu.pk</a></p>
<p dir="auto">GOOD LUCK</p>
]]></description><link>https://community.secnto.com//topic/536/cs502-assignment-no-01-solution-and-discussion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 19:59:45 GMT</lastBuildDate><atom:link href="https://community.secnto.com//topic/536.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 12 Nov 2019 10:42:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CS502 Assignment No. 01 Solution and Discussion on Thu, 05 Dec 2019 08:30:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zareen" aria-label="Profile: zareen">@<bdi>zareen</bdi></a> said in <a href="/post/1458">CS502 Assignment No. 01 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Question No 02: (Marks: 10)<br />
You are required to calculate (Step by Step) the worst case time complexity T(n) of the algorithm designed in Question No. 01.</p>
</blockquote>
<p dir="auto"><strong>Solution:</strong><br />
Question No. 02: The step by stem analysis of the algorithm designed in question 1 is as follow,</p>
<p dir="auto">The time taken by each statement (step) is given as follows,</p>
<p dir="auto">Step 1:   C1                       // Execute only 1 time or Constant Time or  O (1)<br />
Step 2:   C2                       // Execute only 1 time or Constant Time or  O (1)<br />
Step 3:   n -2                    // Execute n -2 times<br />
Step 4:   n -2                    // Execute n -2 times<br />
Step 5:   n – 2                  // Execute n -2 times<br />
Step 6:   C3                      // Execute only 1 time or Constant Time or  O (1)<br />
Step 7:   C4                                  // Execute only 1 time or Constant Time or  O (1)<br />
Step 8:   C5                                  // Execute only 1 time or Constant Time or  O (1)<br />
Step 9:   C6                                 // Execute only 1 time or Constant Time or  O (1)</p>
<p dir="auto">Total time T(n) can be calculated as follows,</p>
<p dir="auto">T(n)    = C1 + C2 + (n -2 ) + (n -2 ) + (n -2 ) + C3 + C4 + C5 + C6<br />
T(n)    = C1 + C2 + n -2 + n -2  + n -2  + C3 + C4 + C5 + C6<br />
T(n)    = C1 + C2 + n  + n   + n - 6  + C3 + C4 + C5 + C6<br />
T(n)    =  3n + C1 + C2   + C3 + C4 + C5 + C6 -6<br />
T(n)    =  3n + (C1 + C2   + C3 + C4 + C5 + C6 -6)<br />
T(n)    =  3n + C7                                                              //  C7  = (C1 + C2   + C3 + C4 + C5 + C6 -6)<br />
T(n)    =  n                                                                       //   Ignoring constant terms</p>
<p dir="auto">Or      T(n)   =  O (n )</p>
]]></description><link>https://community.secnto.com//post/2203</link><guid isPermaLink="true">https://community.secnto.com//post/2203</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Thu, 05 Dec 2019 08:30:14 GMT</pubDate></item><item><title><![CDATA[Reply to CS502 Assignment No. 01 Solution and Discussion on Thu, 05 Dec 2019 08:28:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zareen" aria-label="Profile: zareen">@<bdi>zareen</bdi></a> said in <a href="/post/1458">CS502 Assignment No. 01 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Question No  01:   (Marks:  10)<br />
You are required to design (write) a simple algorithm (Only Pseudo code) which can identify a number to be Prime or Not Prime.</p>
</blockquote>
<p dir="auto"><strong>Solution:</strong><br />
Question No. 01:  The algorithm for the identification of Prime number is as follows,</p>
<p dir="auto">1	  PRIME (int  Number)<br />
2	  int Count ← 0<br />
3	  for i ← 2 to Number – 1<br />
4	        if ( Number % i equal to 0)<br />
5	        Increment Count<br />
6	  If (Count is equal to 0)<br />
7	  Number is Prime<br />
8	  else<br />
9	  Number is NOT Prime</p>
]]></description><link>https://community.secnto.com//post/2202</link><guid isPermaLink="true">https://community.secnto.com//post/2202</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Thu, 05 Dec 2019 08:28:18 GMT</pubDate></item><item><title><![CDATA[Reply to CS502 Assignment No. 01 Solution and Discussion on Thu, 21 Nov 2019 12:09:07 GMT]]></title><description><![CDATA[<p dir="auto">Question No. 02: The step by stem analysis of the algorithm designed in question 1 is as follow,</p>
<p dir="auto">The time taken by each statement (step) is given as follows,</p>
<p dir="auto">Step 1:   C1                       // Execute only 1 time or Constant Time or  O (1)<br />
Step 2:   C2                       // Execute only 1 time or Constant Time or  O (1)<br />
Step 3:   n -2                    // Execute n -2 times<br />
Step 4:   n -2                    // Execute n -2 times<br />
Step 5:   n – 2                  // Execute n -2 times<br />
Step 6:   C3                      // Execute only 1 time or Constant Time or  O (1)<br />
Step 7:   C4                                  // Execute only 1 time or Constant Time or  O (1)<br />
Step 8:   C5                                  // Execute only 1 time or Constant Time or  O (1)<br />
Step 9:   C6                                 // Execute only 1 time or Constant Time or  O (1)</p>
<p dir="auto">Total time T(n) can be calculated as follows,</p>
<p dir="auto">T(n)    = C1 + C2 + (n -2 ) + (n -2 ) + (n -2 ) + C3 + C4 + C5 + C6<br />
T(n)    = C1 + C2 + n -2 + n -2  + n -2  + C3 + C4 + C5 + C6<br />
T(n)    = C1 + C2 + n  + n   + n - 6  + C3 + C4 + C5 + C6<br />
T(n)    =  3n + C1 + C2   + C3 + C4 + C5 + C6 -6<br />
T(n)    =  3n + (C1 + C2   + C3 + C4 + C5 + C6 -6)<br />
T(n)    =  3n + C7                                                              //  C7  = (C1 + C2   + C3 + C4 + C5 + C6 -6)<br />
T(n)    =  n                                                                       //   Ignoring constant terms</p>
<p dir="auto">Or      T(n)   =  O (n )</p>
]]></description><link>https://community.secnto.com//post/1831</link><guid isPermaLink="true">https://community.secnto.com//post/1831</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Thu, 21 Nov 2019 12:09:07 GMT</pubDate></item><item><title><![CDATA[Reply to CS502 Assignment No. 01 Solution and Discussion on Thu, 21 Nov 2019 12:08:23 GMT]]></title><description><![CDATA[<p dir="auto">Solution:<br />
Question No. 01:  The algorithm for the identification of Prime number is as follows,</p>
<p dir="auto">1	  PRIME (int  Number)<br />
2	  int Count ← 0<br />
3	  for i ← 2 to Number – 1<br />
4	        if ( Number % i equal to 0)<br />
5	        Increment Count<br />
6	  If (Count is equal to 0)<br />
7	  Number is Prime<br />
8	  else<br />
9	  Number is NOT Prime</p>
]]></description><link>https://community.secnto.com//post/1830</link><guid isPermaLink="true">https://community.secnto.com//post/1830</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Thu, 21 Nov 2019 12:08:23 GMT</pubDate></item><item><title><![CDATA[Reply to CS502 Assignment No. 01 Solution and Discussion on Sat, 16 Nov 2019 15:04:06 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://drive.google.com/file/d/1-66NDYdsH_ed1pa7NdLJoHLH62_h2Wgx/view" target="_blank" rel="noopener noreferrer nofollow ugc">Download Complete Ideas Solution </a></p>
]]></description><link>https://community.secnto.com//post/1506</link><guid isPermaLink="true">https://community.secnto.com//post/1506</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Sat, 16 Nov 2019 15:04:06 GMT</pubDate></item><item><title><![CDATA[Reply to CS502 Assignment No. 01 Solution and Discussion on Wed, 13 Nov 2019 10:12:35 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://youtu.be/67UYCPkunp8" target="_blank" rel="noopener noreferrer nofollow ugc">https://youtu.be/67UYCPkunp8</a></p>
]]></description><link>https://community.secnto.com//post/1505</link><guid isPermaLink="true">https://community.secnto.com//post/1505</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Wed, 13 Nov 2019 10:12:35 GMT</pubDate></item><item><title><![CDATA[Reply to CS502 Assignment No. 01 Solution and Discussion on Wed, 13 Nov 2019 10:12:26 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://youtu.be/rMDRSju4lZQ" target="_blank" rel="noopener noreferrer nofollow ugc">https://youtu.be/rMDRSju4lZQ</a></p>
]]></description><link>https://community.secnto.com//post/1504</link><guid isPermaLink="true">https://community.secnto.com//post/1504</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Wed, 13 Nov 2019 10:12:26 GMT</pubDate></item><item><title><![CDATA[Reply to CS502 Assignment No. 01 Solution and Discussion on Wed, 13 Nov 2019 10:12:21 GMT]]></title><description><![CDATA[<p dir="auto"><img src="/assets/uploads/files/1573639923094-ae14b10f-49e9-4fc5-bcb4-1013e8c3772a-image.png" alt="ae14b10f-49e9-4fc5-bcb4-1013e8c3772a-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/1503</link><guid isPermaLink="true">https://community.secnto.com//post/1503</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Wed, 13 Nov 2019 10:12:21 GMT</pubDate></item></channel></rss>