Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
U

User 10395751

@User 10395751
About
Posts
5
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • I need a two level priority queue
    U User 10395751

    Finded it, thanks for your help! :)

    C / C++ / MFC data-structures career

  • I need a two level priority queue
    U User 10395751

    I tried but didn't find the problem. Do you have an idea?

    C / C++ / MFC data-structures career

  • I need a two level priority queue
    U User 10395751

    I add this one.

    while(presentPtr != NULL && type > presentPtr->userType){
    prevPtr = presentPtr;
    presentPtr = presentPtr->nextPtr;
    }

    if(type == presentPtr->userType){
    while(presentPtr != NULL && p > presentPtr->pages){
    prevPtr = presentPtr;
    presentPtr = presentPtr->nextPtr;
    }
    }

    C / C++ / MFC data-structures career

  • I need a two level priority queue
    U User 10395751

    I used this code.

    void enqueue(char type, int p){
    struct node *newPtr, *prevPtr, *presentPtr,*tempPresent;

    //Allocating memory for new member
    newPtr = malloc(sizeof(struct node));
    
    //Checking allocation. If there is not room for new member in RAM then it gives an error
    if(newPtr != NULL){
    	newPtr->pages = p;
    	newPtr->userType = type;
    	newPtr->nextPtr = NULL;
    	
    	prevPtr = NULL;
    	presentPtr = front;
    	
    	while(presentPtr != NULL && type > presentPtr->userType){
    		prevPtr = presentPtr;
    		presentPtr = presentPtr->nextPtr;
    	}
    	//Checking if new member is the first element of the linked list or not
    	if(prevPtr == NULL){
    		newPtr->nextPtr = front;
    		front = newPtr;
    	}
    	else{
    		prevPtr->nextPtr=newPtr;
    		newPtr->nextPtr=presentPtr;
    	}
    }//If allocation fails throws a message to the user
    else{
    	printf("System out of memory!");
    }
    

    }

    This code moves along first priority. But when I add a page check in this loop then it goes infinite loop. What will be the solution?

    while(presentPtr != NULL && type > presentPtr->userType){
    prevPtr = presentPtr;
    presentPtr = presentPtr->nextPtr;
    }

    C / C++ / MFC data-structures career

  • I need a two level priority queue
    U User 10395751

    Hey, I need a C code which builds the printer job queue. However, the printer job queue is built as a two level priority queue.

    C / C++ / MFC data-structures career
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups