Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

pseudo code, priority queues.

Options
  • 01-09-2009 2:06pm
    #1
    Registered Users Posts: 50 ✭✭


    hey i have this question:

    "Write down the pseudo code for the princeple methods you would use to implement a priority queue as an ordered sequence using a linked list."

    im using thompsons c++ programming and havnt seen too much pseudo code or even priority queues!

    im just wondering if anyone could give me a sample solution?

    Thanks very much!


Comments

  • Closed Accounts Posts: 95 ✭✭jingx3


    I don't know too much about priority qeues but I know some pseudo code.
    #!/bin/jc
      v=: ?. 20 $ 100     NB. a random vector
      v
    46 55 79 52 54 39 60 57 60 94 46 78 13 18 51 92 78 60 90 62
      avg v
    59.2
      
      4 avg\ v            NB. moving average on periods of size 4
    58 60 56 51.25 52.5 54 67.75 64.25 69.5 57.75 38.75 40 43.5 59.75 70.25 80 72.5
      
      m=: ?. 4 5 $ 50     NB. a random matrix
      m
    46  5 29  2  4
    39 10  7 10 44
    46 28 13 18  1
    42 28 10 40 12
      
      avg"1 m             NB. apply avg to each rank 1 subarray (each row) of m
    17.2 22 21.2 26.4
    exit ''
    

    Hope that helps.


  • Registered Users Posts: 1,916 ✭✭✭ronivek


    Not trying to be smart here but all the resources you need are readily available;

    http://en.wikipedia.org/wiki/Priority_queue

    http://en.wikipedia.org/wiki/Pseudocode

    Between those two pages alone you should be able to come up with an acceptable solution.

    Just remember there's no strictly right or wrong way to write pseudocode; it's merely a means to represent an algorithm in a format that should be easy for just about anyone with a passing knowledge of programming to understand.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    If you get people to do your homework for you, how are you supposed to learn how to program. Have a read of the forum charter before you post again.


This discussion has been closed.
Advertisement