Computer Notes, Programming codes, Hardware and Networking Tip, Entertainment, Biography, Internet Tip, Tech News, Latest Technology, YouTube,

Latest Post
About RAM Advantages of multiprocessing system Associative memory Binary Number System CA CA Notes Change drive icon change pendrive icon Computer Abbreviation Computer Architecture Computer fundamental MCQ Computer Generation Computer generation computer notes Computer MCQ Computer Network MCQ Computer Operator MCQ Critical Section Critical section in OS Database connectivity in java Deadlock avoidance Deadlock detection algorithm Deadlock Detection and Recovery Deadlock detection method Deadlock Handling Deadlock in OS Deadlock Prevention Deadlock Recovery define object and class Define system cell Descrete Structure Device Driver Device driver in computer device driver in os DFA DFA contains with DFA ends with dfa examples dijkstra's algorithm Discrete Structure Discrete Structure graph theory Download JDBC Driver Download MySql Download PUBG DS DS Notes FCFS Job Scheduling Algorithm Finding shortest path Finite Sate Automata Flynn's Classifications fragmentation in computer fragmentation in harddisk fragmentation in os fragmented memory Full form related to computer Generations of operations Generations of OS Graph theory ICT 1st semester notes Instruction Address Modes Java java array declaration java class and object example Java Database connectivity example java event handling example program Java JDBC Java JMenuBar Java JSP program example java notes java program methods example Java program to create class and object java program to create methods java program to print even number between any two numbers Java programming java programming notes Java programs Java question answer java swing example java swing program to calculate simple interest Java Tutorials JSP program learn qbasic Lekh MCQ MCQ Computer MCQ Operating System memory fragmentation MICT 1st semester notes mict 1st semester operating system notes MICT first semester notes Multiprocessing mutex in os Necessary conditions for deadlock Number System Operating System Operating system notes OS OS Notes OS Numeric pattern printing program in qbasic patterns in qbasic Pipeline Hazards Pipelining Pipelining concept prime or composite in qbasic print patterns qbasic print series in qbasic Printing Series in qbasic PUBG PUBG Mobile PUBG PC PUBG Story qbasic qbasic code qbasic for class 10 qbasic for class 8 qbasic for class 9 qbasic for school QBASIC Pattern printing qbasic pattern printing program qbasic pattern printing programs qbasic pattern types qbasic patterns qbasic programming tutorials qbasic programs qbasic sequence printing programs qbasic tutorials Race Condition in Operating system reverse order in qbasic RISC and CISC RISC Pipeline Scheduling algorithm segmentation in operating system segmentation in os semaphore and mutex Semaphore concept in os Semaphore in os semaphore in os notes semaphore meaning sequential programs in qbasic series in qbasic series printing programs in qbasic shell in operating system shell in os shortest path shortest path algorithm simple interest program in java swing System Bus System Cell Teach Blog Tech Blog Tech School technical school The Shell in Operating system types of fragmentation Types of Multiprocessor types of operating system Types of pipeline hazards View Connected Wifi password Virtual Memory Virtual memory in OS Von Neumann's architecture What is associative memory? what is class? What is computer system? What is Fragmentation? What is jsp? what is object? What is process? What is segmentation What is System Cell What is Thread? what is virtual memory in computer What is virtual memory? पब्जी गेम



Dijkstra's algorithm is used to find the shortest path between source vertex (a) to destination vertex (b).


According to Dijkstra's algorithm, to find the shortest path from source vertex to destination vertex we need to follow the following steps.
Step 1: Remove all the loops
Step 2: Remove all parallel edges between two vertices except the one with least weight.
Step 3: Create the weight matrix table
            i) Set 0 to the source vertex and infinite to the remaining vertices.
                        For all vertices, repeat (ii) and (iii)
            ii) Mark the smallest unmarked value and mark that vertex.
            iii) Find those vertices which are directly connected with marked vertex and update all.
                  Update value formula:
                  New Destination value = Minimum(Old destination value, Marked value + Edge weight)
Step 4: Perform backtrack
Some Examples: 

1. Find shortest path from a to g. 



2. Find shortest path from a to c. 


QBASIC Program to print the given string in reverse order

CLS
INPUT "Enter any String "; s$
FOR i = LEN(s$) TO 1 STEP -1
    r$ = MID$(s$, i, 1)
    b$ = b$ + r$
NEXT i
PRINT "Reverse Order = "; b$
END

Using SUB .... END SUB

DECLARE SUB revf(s$)
CLS
INPUT "Enter any String "; s$
CALL rev(s$)
END

SUB rev (s$)
    FOR i = LEN(s$) TO 1 STEP -1
        r$ = MID$(s$, i, 1)
        b$ = b$ + r$
    NEXT i
    PRINT "Reverse Order = "; b$
END SUB



Using FUNCTION ... END FUNCTION

DECLARE FUNCTION rev$(s$)
CLS
INPUT "Enter any string "; s$
re$ = rev$(s$)
PRINT "Reverse Order = "; re$
END

FUNCTION rev$ (s$)
    FOR i = LEN(s$) TO 1 STEP -1
        r$ = MID$(s$, i, 1)
        b$ = b$ + r$
    NEXT i
    rev$ = b$
END FUNCTION


Video Tutorial in Nepali Language

The number of address fields in the instruction format depends on the internal organization of CPU. On the basis of no. of address field, we can categories the instruction as bellow.
  • Three Address Instruction : Memory addresses for the two operands and one destination need to be specified. It is also called General register organization. 
  • Two Address Instruction : Two address registers or two memory locations are specified. Assumes that the destination address is the same as that of the first operand. 
  • One Address Instruction : One address can be a register name or memory address. It uses AC (Accumulator) register for all data manipulation. It is also called single accumulator organization. 
  • Zero Address Instruction : Stack is used. Arithmetic operation pops two operands from the stack and pushes the result. It is also called stack organization. 


CA Assignment (MICT 1st Sem)

Write instruction of following expression using 3, 2, 1 and 0 address instruction format.

a)  Y = (A+B) * C

      Three (3) address instruction format 
         ADD R1, A, B         // R1 = M[A] + M[B]
         MUL Y, R1, C         // M[Y] = R1 * M[C]

      Two (2) address instruction format 
         MOV R1, A          // R1 = A
         ADD R1, B           // R1 = R1 + M[B]
         MOV R2, C          // R2 = M[C]
         MUL R1, R2        // R1 = R1 * R2
         MOV Y, R1          // M[Y] = R1 

      One (1) address instruction format 
        LOAD A            // AC = M[A]
        ADD B              // AC = AC + M[B]
        MUL C              // AC = AC * M[C]
        STORE Y          // M[Y] = AC 

      Zero (0) address instruction format 
        PUSH A             // TOS = M[A]
        PUSH B             // TOS = M[B]
        ADD                  // TOS = M[A] + M[B]
        PUSH C             // TOS = M[C]
        MUL                  // TOS = (M[A] + M[B]) * M[C]
        POP Y                // M[Y] = TOS

b)  Z = (A*C+D)*A

      Three (3) address instruction format 
      MUL R1, A, C          // R1 = M[A] * M[C]
      ADD R2, R1, D        // R2 = R1 + M[D]
      MUL Z, R2, A          // M[Z] = R2 * M[A] 

      Two (2) address instruction format 
       MOV R1, A          // R1 = M[A]
       MUL R1, C           // R1 = R1 * M[C]
       MOV R2, D          // R2 = M[D]
       ADD R1, R2         // R1 = R1 + R2 
       MUL R1, A           // R1 = R1 * M[A]
       MOV R1, Z           // M[Z] = R1

      One (1) address instruction format   Z = (A*C+D)*A
        LOAD A               // AC = M[A]
        MUL C                 // AC = AC * M[C]
        ADD D                 // AC = AC + M[D]
        MUL A                 // AC = AC * M[A]
        STORE Z             // M[Z] = AC
                            
      Zero (0) address instruction format 
        PUSH A              // TOS = M[A]
        PUSH C              // TOS = M[C]
        MUL                   // TOS = M[A] * M[C]
        PUSH D              // TOS = M[D] 
        ADD                   // TOS = (M[A] * M[C]) + M[D])
        PUSH A              // TOS = M[A]
        MUL                   // TOS =  (M[A] * M[C]) + M[D]) * M[A] 
        POP Z                 // M[Z] = TOS



c)  Y = {(A+B)*C}+D

      Three (3) address instruction format 
      ADD R1, A, B         // R1 = M[A] + M[B] 
      MUL R2, R1, C       // R2 = R1 * M[C]
      ADD Y, R2, D         // M[Y] = R2 + M[D]

     Two (2) address instruction format 
       MOV R1, A           // R1 = M[A]
       ADD R1, B            // R1 = R1 + M[B]
       MOV R2, C           // R2 = M[C]
       MUL R1, R2          // R1 = R1 * R2
       MOV R3, D           // R3 = M[D]
       ADD R1, R3          // R1 = R1 + R3 
       MOV Y, R1            // M[Y] = R1

      One (1) address instruction format (Y = {(A+B)*C}+D)
       LOAD A           // AC = M[A]
       ADD B              // AC = AC + M[B]
       STORE T          // M[T] = AC 
       LOAD C           // AC = M[C]
       MUL T             // AC = AC * M[T]
       ADD D             // AC = AC + M[D]
       STORE Y         // M[Y] = AC

      Zero (0) address instruction format 
        PUSH A           // TOS = M[A]
        PUSH B           // TOS = M[B] 
        ADD                // TOS = M[A] + M[B]
        PUSH C          // TOS = M[C]
        MUL                // TOS = (M[A]+M[B])*M[C]
        PUSH D          // TOS = M[D]
        ADD                // TOS = {(M[A]+M[B])*M[C]}+M[D]
        POP Y             // M[Y] = TOS
     
      

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget