+ All Categories
Home > Documents > Algorithms Question Answers Set1

Algorithms Question Answers Set1

Date post: 17-Feb-2018
Category:
Upload: kiran
View: 241 times
Download: 0 times
Share this document with a friend

of 42

Transcript
  • 7/23/2019 Algorithms Question Answers Set1

    1/42

    PAPER-VII

    ALGORITHMS

    What is time and space complexity?

    Ans:- Time complexitya function which

    describes the amount of time an algorithm

    akes in terms of the amount of i/p to thealgorithm.

    Space complexitya function whichdescribes the amount of memory (space)

    an algorithm takes in terms of the amount

    of input to the algorithm.

    Dijkstra's Algorithm:-The time required

    by Dijkstra's algorithm is O(|V|2). It wil

    be reduced to O(|E|log|V|) if heap is used

  • 7/23/2019 Algorithms Question Answers Set1

    2/42

    o keep {v in V\Si: L(v) < infinity}.

    Prim's Algorithm:-The time required by

    Prim's algorithm is O(|V|2). It will beeduced to O(|E|log|V|) if heap is used to

    keep {v in V\Si: L(v) < infinity}.

    Kruskal algorithm:- The time requiredby Kruskal's algorithm is O(|E|log|V|).

    Travelling Salesman Problem.:-It is a

    raditional issue that has to do witmaking the most efficient use of resource

    while at the same time expending the leas

    amount of energy in that utilization. The

    designation for this type of problem hail

    back to the days of the travelingsalesman

    who often wished to arrange travel in a

    manner that allowed for visiting the mos

  • 7/23/2019 Algorithms Question Answers Set1

    3/42

    owns without having to double back and

    cross into any given town more than once

    Poission process:-It is a collectio{N(t) : t 0} of random variables

    where N(t) is the number of events tha

    have occurred up to time t (starting fro

    ime 0). The number of events betweeime aand time bis given asN(b) N(a

    and has aPoisson distribution

    Each realization of the process {N(t)} i

    a non-negative integer-valued step

    function that is non-decreasing, but fo

    ntuitive purposes it is usually easier to

    hink of it as a point pattern on [0,) (thepoints in time where an event occurs)

    The Poisson process is a continuous-time

    process. A Poisson process is a pure

    birth process, the simplest example o

    http://en.wikipedia.org/wiki/Realization_(probability)http://en.wikipedia.org/wiki/Poisson_distributionhttp://en.wikipedia.org/wiki/Random_variable
  • 7/23/2019 Algorithms Question Answers Set1

    4/42

    a birth-death process.

    Inclusion Principal:- The principle thatfA and B are finite sets, the number o

    elements in the union of A and B can be

    obtained by adding the number o

    elements in A to the number of elementn B, and then subtracting from this sum

    s the number of elements in the

    ntersection ofAandB.

    Propositional Satisfiability Problem:-A

    propositional satisfiability problembriefly called SAT, consists of a

    formula F 2 L(R), and is the problem to

    decide whether F is satisfiable.

    http://en.wikipedia.org/wiki/Birth-death_process
  • 7/23/2019 Algorithms Question Answers Set1

    5/42

    SAT is a combinatorial decisio

    problem.

    1. Decision variant yes/no

    answer .2. Search variant find a model i

    F is satisfiable

    BFS AND DFS

    Breadth-first Search:-

    The general idea behinda breadth-first search beginning

    at a starting vertex A is as

    follows. First we process the

  • 7/23/2019 Algorithms Question Answers Set1

    6/42

    starting vertex A.Then

    we process all the neighbors

    of A.Then we process allthe neighbors of neighbors

    of AAnd so on. Naturally we

    need to keep track of theneighbors of a

    vertex, andwe need toguarantee

    that no vertex is processed twiceThis is accomplished by using a

    QUEUE to hold vertices that arc

    waiting to he processed, and bya field STATUS which tells us the

    current status

  • 7/23/2019 Algorithms Question Answers Set1

    7/42

    of a vertex.The algorithm follows

    Algorithm (Breadth-first Search):This algorithm executes a breadth-firstsearch on a graph G beginning with astarling vertex A

    Step 1. Initialize all vertices to theeady state (STATUS = 1)

    Step 2. Put the starting vertex A inQUEUE and change the status of A tohe waiting state (STATUS =2).

    Step3. Repeat Steps 4 and 5 untilQUEUE is empty.

    Step 4.Remove the front vertex No ofQUEUE. Process N, and set STATUS (N)= 3, the processed state.

    Step 5. Examine each neighbor J of N

  • 7/23/2019 Algorithms Question Answers Set1

    8/42

    a) If STATUS (J)= 1 (ready state), add Jo the rear of QUEUE and reset

    STATUS (J) - 2 (waiting state).

    b) If STATUS (J) = 2 (waiting state) orSTATUS (J) = 3 (processed state), ignorehe vertex J.

    [End of Step 3 loop.]

    Step 6.Exit.

    Again, the above algorithm will process

    only those vertices which are connectedo the starting vertex A.that is,he connected componentncluding A. Suppose

    one wants to process all the vertices in

    he graph G. Then the algorithm must bemodified so that itbegins again with another vertex (whichwe callB) that is still in the ready stateSTATUS = 1).

    This vertex Bain be obtained by

  • 7/23/2019 Algorithms Question Answers Set1

    9/42

    raversing through thelist of vertices.

    EXAMPLESuppose the BFS Algorithm 8.1? B is

    applied to the graph in Fig. 8-28. Thevertices are processed in the followingorder:A, D, C, B, F, E, G, HSpecifically, Figure (a)shows thesequence of waiting lists in QUEUE andhe vertices being processedAgain,

    each vertex, excluding A,comes froman adjacency list and hence correspond-

    to an edge of thegraph. Theseedges form a spanning tree of G whichs pictured in Figure (b).

    Again,the numbersindicate theorder the ed

    are added to the tree.Observe that this spanning tree isdifferent than the one inFigure (b) which came from a depth-firstsearch

  • 7/23/2019 Algorithms Question Answers Set1

    10/42

    Depth-first Search:The generaldea behind a depth-first search

    beginning at a starting

    vertex A is as fellows First weprocess the starting

    vertex A. Then we process each

    vertex N along with a

  • 7/23/2019 Algorithms Question Answers Set1

    11/42

    path P which begins at A;that is,

    we process a neighbor of A, then

    a neighbor of a neighborof A, and so on. After coming to

    a "dead end", that is, to a vertex

    with no unprocessed neighbor,we backtrack on the path P until

    we can continue along another

    path P. And so on. Thebacktracking is accomplished by

    using a STACK to hold the initia

    vertices of future possiblepaths. We also need a field

    STATUS which tells us the

  • 7/23/2019 Algorithms Question Answers Set1

    12/42

    current status of any vertex so

    that no vertex is processed more

    than once. The algorithmfollows.

    Algorithm 1.12A (Depth-first Search):

    This algorithm executes a depth-firstsearch on a graph G beginning with astarting vertex A.

    Step 1. Initialize all vertices to the

    eady state (STATUS = I)

    Step 2. Push the startingvertex A onto STACK and change thestatus of A to the waiting state (STATUS= 2).

    Step 3. Repeat Steps 4 and 5 untilSTACK is empty.

    Step 4. Pop the top vertex N of

  • 7/23/2019 Algorithms Question Answers Set1

    13/42

    STACK. Process N, and set STATUS (N)= 3; the processed state

    Step 5. Examine

    each neighbor J of N.

    a) If STATUS (J)= 1(ready slate),push Jonto STACK and resetSTATUS (J) = 2 (waiting state).

    b) If STATUS (J)= 2(waiting state),delete the previous J from the STACKand push the current J onto STACK

    c) If STATUS (J)= 3(processed state),gnore the vertex J.

    [End of Step 3 loop.]

    Step 6. Exit.

    The above algorithm will process onlyhose vertices which are

    connected tothe starting vertex

    A, thatis. the connected component

  • 7/23/2019 Algorithms Question Answers Set1

    14/42

    ncluding A. Suppose one wants toprocess all the vertices in thegraph G.Then the algorithm must bemodified so that it begins

    again withanother vertex (which wecall B) that isstill in the ready stateSTATE - 1). This vertex B can be

    obtained by traversing through the list ofvertices.

    EXAMPLESuppose the DFS Algorithm1.12A isapplied to the graph in fig 1-28.

    The vertices are processed in thefollowing order:A, B, E, F, C, G, H, D

    Specifically, Fig. (a) shows thesequenceof waiting lists in STACK and the

    vertices being processed. We have usedhe slash to indicate that a vertexs deleted from the waiting list. Each

    vertex, excludingA, comes froman adjacency list and hence

    corresponds to an edge

  • 7/23/2019 Algorithms Question Answers Set1

    15/42

    of thegraph. Theseedges formaspanning trof G which is pictured in Fig. (A). Thenumbers indicate the orderhat the edges arcadded to the

    ree, and the dashed lines indicatebacktracking.

    SATELLITE

    COMMUNICATION

  • 7/23/2019 Algorithms Question Answers Set1

    16/42

    A Geosynchronous Earth

    Orbit (GEO):- This

    satellite has an orbita

    period that synchronizes

    with the Earths speed orotation. So, for an

    observer at a fixed location

    on Earth, a GEO satellite

    will always return to the

    same place in the sky aexactly the same time each

    day.

  • 7/23/2019 Algorithms Question Answers Set1

    17/42

    It is also used in the Geo-

    Stationary Earth

    Orbit(GSO) satellite, it is

    a special type of GEO, in

    which the satellite is placedin orbit directly above the

    Earths equator at a precise

    height, so that it maintains

    the same position relative to

    the Earths surface.

    Middle Earth Orbit (MEO):-Thi

    satellites have orbits ranging from a few

  • 7/23/2019 Algorithms Question Answers Set1

    18/42

    hundred miles to a few thousand mile

    above the earth's surface, with orbita

    periods ranging from around two to 12

    hours. MEO is used mainly for satellitenavigation systems such as GPS, Galileo

    Glonass and Beidu.

    LOW EARTH ORBIT(LEO):-LEO

    systems fly about 500 to 1,500 kilometer

    above the Earth. Aypical LEO satellite takes less than two

    hours to orbit the Earth,

    and are only visible for 15 to 20 minute

    each pass.Low earth orbiting satellitesare less expensive to launch into orbit as

    distance from the earth is less, don't

    equire as high signal strength and give

  • 7/23/2019 Algorithms Question Answers Set1

    19/42

    ess time delay.

    Meaning of DPCM Differentia

    Pulse Code Modulation- It is amodulation technique invented by the

    British Alec Reeves in 1937. It is a

    digital representation of an analog signa

    where the magnitude of the signal i

    sampled regularly at uniform intervals

    Every sample is quantized to a series o

    symbols in a digital code, which iusually a binary code. PCM is used i

    digital telephone systems. It is also the

    standard form for digital audio i

    computers and various compact discformats. DPCM allows this to be

    achieved by describing only the change

    between the samples.

    http://www.birds-eye.net/definition/p
  • 7/23/2019 Algorithms Question Answers Set1

    20/42

    ADVANTAGES AND

    DISADVANTAGES OF OSI MODEL

    Advantages:-1)It provides a standard to

    design networking devices by differen

    vendors.

    2)The protocols in OSI are much hidde

    han TCP/IP and can be replaced

    elatively easily as the technology

    changes.

    3) OSI supports both connectionless and

    connection-oriented communication in the

    network layer

    Disadvantages:-1)Due to the complexity

    of the system poor performance i

  • 7/23/2019 Algorithms Question Answers Set1

    21/42

    obtained, especially in some real time

    applications.

    2) Direct substitution of layers is noalways possible e.g. if a LAN wit

    broadcast capability is inserted below a

    network protocol that did not support thi

    facility, then this service would be lost tohe upper layers.

    3) Although protecting equipment fro

    becoming obsolete it simultaneouslyhinders technological advancement.

    DATA TRANSMISSION

    The transmission mode refers to the

    number of elementary units of informatio

    bits) that can be simultaneously

    ranslated by the communications channel

  • 7/23/2019 Algorithms Question Answers Set1

    22/42

    PARALLEL

    CONNECTION:-

    Parallel connectio

    means simultaneouransmission ofNbits. These bits are sen

    simultaneously overNdifferent channels.

    SERIALCONNECTION: -In aserial connection, the dataare sent one bit at a time

    over the transmission channel. Howeversince most processors process data iparallel, the transmitter needs toransform incoming parallel data into

    serial data and the receiver needs to dohe opposite.

    Asynchronous data transmission mode:

  • 7/23/2019 Algorithms Question Answers Set1

    23/42

    n this mode, each character is sent a

    rregular intervals in time. So, fo

    example, imagine that a single bit i

    ransmitted during a long period osilence... the receiver will not be able to

    know if this i

    00010000,10000000,00000100 . To

    emedy this problem, each character i

    preceded by some information indicatin

    he start of character transmission (the

    ransmission start information is calleda START bit) and ends by sending end-of

    ransmission information (called STOP

    bit, there may even be several STOP

    bits).

    ADVANTAGES: - 1)It is faster means o

    connecting 2) It is Simple. 3) Doesn

    equire synchronization of bot

  • 7/23/2019 Algorithms Question Answers Set1

    24/42

    communication sides. 4)H/W cost is very

    cheap.

    DISADVANTAGES:-1)It is less reliable2) Large relative overhead. 3) a hig

    proportion of the transmitted bits are

    uniquely for control purposes and thu

    carry no useful information.

    Synchronous data transmission mode:

    n this mode, the transmitter and receive

    are paced by the same clock. The

    eceiver continuously receives (eve

    when no bits are transmitted) thenformation at the same rate the

    ransmitter send it. This is why the

    ransmitter and receiver are paced at the

    same speed

  • 7/23/2019 Algorithms Question Answers Set1

    25/42

    ADVANTAGES:- 1) supplementary

    nformation is inserted to guarantee tha

    here are no errors during transmission.

    2) It is highly efficient. 3)Lower

    overhead and thus, greater throughput 4

    t is more reliable.

    5)It is possible to have both sides try to

    synchronize the connection at the same

    ime.

    DISDVANTAGES:- 1)The mai

    disadvantage of synchronous transmissio

    s recognising the data at the receiver.

    2)It is slower than asynchronou

    ransmission mode. 3)Hardware is more

    expensive 4)Slightly more complex.

  • 7/23/2019 Algorithms Question Answers Set1

    26/42

    ALOHA

    ALOHA is a medium access protocol thawas originally designed for ground based

    adio broadcasting however it i

    applicable to any system in whic

    uncoordinated users are competing for the

    use of a shared channel. Pure ALOHA

    and slotted ALOHA are the two version

    of ALOHA.

    Pure ALOHA:- Pure ALOHA uses a

    very simple idea that is to let user

    ransmit whenever they have data to sendPure ALOHA is featured with the

    feedback property that enables it to liste

    o the channel and finds out whether the

    frame was destroyed. Feedback i

    http://www.blurtit.com/q646302.htmlhttp://www.blurtit.com/q328653.html
  • 7/23/2019 Algorithms Question Answers Set1

    27/42

    mmediate in LANsbut there is a delay o

    270 milli sec in the satellitetransmission

    t requires acknowledgment if listening to

    he channel is not possible due to someeason. It can provide a channe

    utilization of 18 percent that is no

    appealing but it gives the advantage o

    ransmitting any time.

    SLOTTED ALOHA:-It divides time

    nto discrete intervals and each interval

    corresponds to a frame of data. It requires

    users to agree on slot boundaries. It does

    not allow a system to transmit any time.

    nstead the system has to wait for thebeginning if the next slot

    Differnce b/w narrowband and

    broadband communication

    http://www.blurtit.com/q898327.htmlhttp://www.blurtit.com/q898327.html
  • 7/23/2019 Algorithms Question Answers Set1

    28/42

    channel:-Narrowband is associated with

    dial up accounts with your ISP usually up

    o speeds of 54kps but can be faster if you

    use ISDN connections.

    Broadband on the other hand is faster

    connections up to 8mb ps and is always

    online ie connected to the Internet evenwhen your PC is switched off

    PAPER IX

  • 7/23/2019 Algorithms Question Answers Set1

    29/42

    OPERATING SYSTEM

    Internal fragmentation:- It occurs

    when storage is allocated withoutntention to use it. This space is

    wasted. While this seems foolish, it is

    often accepted in return for increased

    efficiency or simplicity. The terminternal" refers to the fact that the

    unusable storage is inside the

    allocated region but is not being used.

    t is difficult to reclaim; usually the

    best way to remove it is with a design

    change.

    External fragmentation:- It is the

    phenomenon in which free storage

    becomes divided into many small

    pieces over time. It is a weakness of

  • 7/23/2019 Algorithms Question Answers Set1

    30/42

    certain storage allocation algorithms,

    occurring when an application

    allocates and deallocates regions of

    storage of varying sizes, theallocation algorithm responds by

    eaving the allocated and deallocated

    egions interspersed.. The term

    external" refers to the fact that the

    unusable storage is outside the

    allocated regions.

    Effects:-1)The most common side

    effect of fragmentation is slowdown.

    Fragmentation causes slowdown. 2)

    A rather more serious side effect iswhat file fragmentation is. File

    fragmentation is a direct result of

    external fragmentation,occurs during

    he process of data removal and

  • 7/23/2019 Algorithms Question Answers Set1

    31/42

    expansion, another program. 3)

    Another effect of fragmentation is the

    program to malfunction, i.e function

    slowly or do not function at all.

    Solution:- The only viable solution to

    fragmentation is defragmentation.

    Defragmentation runs a

    comprehensive scan on the hard drive

    and all the files inside of it, and

    determines the optimal way to storeour data. Although defragmentation

    cannot solve internal fragmentation, it

    will completely solve external

    fragmentation.

    Defragmentation is a process tha

    educes the amoun

    of fragmentation in file systems. It doe

    http://en.wikipedia.org/wiki/File_systemhttp://en.wikipedia.org/wiki/File_system_fragmentation
  • 7/23/2019 Algorithms Question Answers Set1

    32/42

    his by physically organizing the content

    of themass storage device to store files i

    a contiguous region if possible, or in the

    smallest possible number of regionfragments) if not. It also attempts to

    create larger regions of free space usin

    compaction to impede the return o

    fragmentation.

    Q) Why paging is used?

    Ans:-Paging is used for faster access

    o data. When a program needs a

    page, it is available in the main

    memory as the OS copies a certain

    number of pages from your storage

    device to main memory. Paging

    allows the physical address space of

    http://en.wikipedia.org/wiki/Contiguityhttp://en.wikipedia.org/wiki/Computer_filehttp://en.wikipedia.org/wiki/Mass_storage
  • 7/23/2019 Algorithms Question Answers Set1

    33/42

    a process to be noncontiguous.

    Advantages of Paging:-1) Easy to

    allocate physical memory 2)Easy toallocate a frame, just remove it from

    ts free list 3) complication for

    kernel contiguous physical memory

    allocation 4) Easy to page outchunks of programs

    Disadvantages of paging:- 1)

    Wastage of memory space. 2)Memory reference overhead 3)

    Memory required to hold page tables

    hat can be large

    Complete Cocomo Model:- The main

    shortcoming of basic and intermediate

    COCOMO model is that they consider a

  • 7/23/2019 Algorithms Question Answers Set1

    34/42

    software product as a single

    homogeneous entity. The system is made

    up of sub-systems which have their own

    characteristics. Sub-systems may havedifferent inherent development

    complexity, reliability requirements may

    be high, development team experience.

    The complete COCOMO model consider

    hese differences in characteristics of the

    subsystems and estimates the effort and

    development time as the sum of theestimates for the individual subsystems.

    Q) What do you mean by S/W quality

    assurance?Ans:- Software Quality Assurancenvolves the entire software developmen

    PROCESS - monitoring and improvin

    he process, making sure that any agreed

  • 7/23/2019 Algorithms Question Answers Set1

    35/42

    upon standards and procedures arefollowed, and ensuring that problems arefound and dealt with. It is oriented to

    prevention'.

    TESTING

    I) Bottom-up Testing Strategy

    1)The subsystem in the lowest layer ofhe call hierarchy are tested individually

    2) Then the next subsystems are testedhat call the previously tested subsystems3)This is done repeatedly until alsubsystems are included in the testin

    Special program needed to do the testing,II) Top-down Testing Strategy

    1) Test the top layer or the controlling

    subsystem first 2) Then combine all the

  • 7/23/2019 Algorithms Question Answers Set1

    36/42

    subsystems that are called by the tested

    subsystems and test the resultin

    collection of subsystems 3)Do this until

    all subsystems are marked into the test4) Special program is needed to do the

    esting,

    Test stub : A program or a method thasimulates the activity of a missin

    subsystem by answering to the callin

    sequence of the calling subsystem and

    eturning back fake data.

    III) Sandwich Testing Strategy

    1) It Combines top-down strategy wit

    bottom-up strategy 2)The system is view

    as having three layers A target layer in the

    middle 3)A layer above the target 4) A

    ayer below the target 5) Testin

  • 7/23/2019 Algorithms Question Answers Set1

    37/42

    converges at the target layer

    IV) Modified Sandwich Testing

    Strategy

    1)Middle layer with drivers and stubs 2

    Top layer with stubs 3) Bottom laye

    with drivers 4) Top layer accessing

    middle layer (top layer replaces drivers)5)Bottom accessed by middle layer

    V) Big-Bang Strategy:-

    Big-Bang approach is very simple in itphilosophy where basically all themodules or builds are constructed andested independently of each other and

    when they are finished, they are all puogether at the same time.Advantage of this approach is that it ivery quick as no drivers or stubs are

    needed, thus cutting down on the

  • 7/23/2019 Algorithms Question Answers Set1

    38/42

    Process CPU

    Burst

    Remainder

    CPU time

    Remaind

    CPU time

    P1 20 16 12

    P2 5 1 0

    P3 6 2 0

    P1 P2 P3 P1 P2 P3 P

    development time.Disadvantage:- 1) the least effective. 2t is very demanding on the resources 3)

    There is really nothing to demonstrateuntil all the modules have been built andntegrated.

    Cpu Scheduling( round robin)

    Quantum = Q = 4

  • 7/23/2019 Algorithms Question Answers Set1

    39/42

    0

    4

    8 12 16 17 19 3

    Average waiting time: Waiting Time =

    Final Start Time - Previous Time i

    CPU - Arrival Time)

    (19-8-0)+(16-4)+(17-4)]/3=

    11+12+13)/3=12

    Every one gets about the same amount o

    waiting time.

    S/W ENG.

    SSADM:- SSADM (Structured System

    Analysis & Design Method) is a widely

    used computer application developmen

  • 7/23/2019 Algorithms Question Answers Set1

    40/42

    method in the UK, where its use is ofte

    specified as a requirement for governmen

    computing projects. It is increasingly

    being adopted by the public sector iEurope.

    SSADM's objectives are to:

    Improve project management &

    control

    Make more effective use of

    experienced and inexperienced

    developmentstaff

    Develop better quality systems

    Make projects resilient to theloss of staff

    Enable projects to be supported

    by computer-based tools such as

    computer-aided software

  • 7/23/2019 Algorithms Question Answers Set1

    41/42

    engineering systems

    Establish a framework for good

    communications between

    participants in a project

    SSADM STEPS:-

    SSADM sets out a cascade or waterfall

    view of systems development, in which

    there are a series of steps, each of

    which leads to the next step,

    SSADM's steps, or stages, are:Feasibility

    Investigation of the current

    environment

    Business systems optionsDefinition of requirements

    Technical system options

    Logical design

  • 7/23/2019 Algorithms Question Answers Set1

    42/42

    Physical design


Recommended