Ads

Pages

Monday, October 31, 2011

CS101 Assignment #01 Solution

Solution:

Q.1. There are multiple ways to enhance the performance of a computer system. Discuss what role a cache can play in boosting up the performance of a computer system? (5 Marks)

Answer:
A CPU cache is a cache used by the central processing unit of a computer to reduce the average time to access memory it is different as compare to the main memory which is used to copy data from the secondary storage it store the data inside the page file and then take it from there as compare to cache memory it exists inside the cpu and directly gives the data to cpu to process the instructions lets see a figure which will make it more clear. The cache is a smaller, faster memory which stores copies of the data from the most frequently used main memory locations. As long as most memory accesses are cached memory locations, the average latency of memory accesses will be closer to the cache latency than to the latency of main memory. It is Volatile memory, also known as volatile storage, is computer memory that requires power to maintain the stored information, When the processor needs to read from or write to a location in main memory, it first checks whether a copy of that data is in the cache. If so, the processor immediately reads from or writes to the cache, which is much faster than reading from or writing to main memory. Most modern desktop and server CPUs have at least three independent caches: an instruction cache to speed up executable instruction fetch, a data cache to speed up data fetch and store, and a translation [vu solutions] look aside buffer (TLB) used to speed up virtual-to-physical address translation for both executable instructions and data. Data cache is usually organized as a hierarchy of more cache levels which are L1 and L2 etc.

Q.2. Generally there is a concept that “Memory” and “Storage” are same terms. Do you agree? Justify your opinion with a real life example. (5 Marks)


Answer:
AS we know nowadays these are very common terms which we use in our daily life so for that you called mostly the Ram as the memory of the system and the Storage device which is called the hard disk or Flash (Usb) memory or can be a memory card. So what’s the difference between them lets see it in real life that in Memory which is Volatile and need powers to maintain if the electricity is off then it is going to wash each and everything. As compare to the Storage Non-Volatile memory which doesn’t need the power all the time when the data is store to it and power went off next time you can see the data inside it. As we can see a new functions which start from the Xp Windows Os from Microsoft. Hibernate it store the data to the hard drive from the Memory You can say the Memory to storage when you hibernate the system it will open next time all the files and applications where you were working. So it’s an example from real life.

Q3).Convert the following Octal Number to Hexadecimal Number by writing each and every step of conversion process: (5 Marks) (53324)8 => (?)16

First we will convert this to binary to decimal

STA630 Online Quiz No. 1 Fall 2011 Announcement

Online Quiz # 01

All Students of Fall Semester 2011 are informed that Online Quiz # 01 for

“Research Methods (STA630)” will be uploaded according to the following schedule:

Opening Date and Time : October 31, 2011 At 12:01 AM

Closing Date and Time : November 01, 2011 At 11:59 PM

CS506 Assignment No. 1 Fall 2011 Solution

Question:

Write a program that computes the average and standard deviation of the text floating point numbers in a file. Use the following formulas for the average and the standard deviation of N values. The formulas compute the sum, the sum of squares, the average, the average square, the variance, and finally, the standard deviation.

sum = x1 + x2 + x3 + ... + xN-1 + xN

sumSQ = x12 + x22 + x32 + ... + xN-12 + xN2

avg = sum/N

avgSQ = sumSQ/N

var = avgSQ - avg2

sd = var(1/2)

The input file will contain any number text floating point numbers, similar to the following:

10.5

12.9

9.67

12.05

8.23

10.08

10.23

7.7

10.4

11.34

Numbers could be several, or none per line, and negative numbers are perfectly OK.

Solution:

Input Text:

10.0

20.0

30.0

40.0

50.0

............

SAVE THIS FILE IN .JAVA

import java.io.*;

import java.util.*;

import javax.swing.*;

public class assignment1{

public static void main( String args[] ){

try{

FileReader fr = null;

BufferedReader br = null;

fr = new FileReader ("input.txt");

br = new BufferedReader (fr);

String line = br.readLine();

double sum =0 ;

while (line != null) {

double num = Double.parseDouble(line);

sum += num;

line = br.readLine();

}

JOptionPane.showMessageDialog(null, "Sum = " + sum);

br.close();

fr.close();

}

catch(NumberFormatException nfEx) {

System.out.println(nfEx);

}

catch(FileNotFoundException fnfEx){

System.out.println(fnfEx);

}

catch(IOException ioEx){

System.out.println(ioEx);

}

}

}

Fin622 Assignment No. 1 Fall 2011 solution

ABC corporation stock is selling for Rs. 150 per share according to Karachi stock exchange market summary. A rumor about the company has been heard that the firm will make an exciting new product announcement next week. By studying the industry, it is being concluded that this new product will support a growth rate of 20% in dividend for two years. After that it is expected that the growth rate in dividend will decline to 6% and remains same onwards. The firm currently pays an annual dividend of Rs. 4.

The rate of return on stocks like ABC Corporation is 10%.

Required:

I. Find out the values for D1, D2 and D3 (8 Marks)

II. What will be the price of stock (P2) at the end of year 2? (4 Marks)

III. What will be the present value (P0) of stock? (6 Marks)

IV. Should we buy stocks of ABC Corporation at Rs. 150? (2 Marks)

Solution

Find out the values for D1, D2 and D3

D1= 4 (1+0.2) =4.8

D2= 4.8 (1+0.2) =5.76

D3=5.76 (1+0.05) =6.11

What will be the price of stock (P2) at the end of year 2?

P2= 5.76 (1+0.2)/ .1-0.05

P2=138.24

What will be the present value (P0) of stock?

PO= 4.8/(1+.1)1 + 5.76/(1+.1)2 + 6.11/(1+.1)3 + 128.31/(1.1)3

= 110

Should we buy stocks of ABC Corporation at Rs. 150

As the present value of the stock is less then the current selling price so the stock should not be purchased.