Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

pseudo code, priority queues.

  • 01-09-2009 02:06PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 1,922 ✭✭✭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, Registered Users 2 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