Skip to content

Commit

Permalink
Adicionado Ordenação por Fila de Prioridades
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Ribas <brunoribas@gmail.com>
  • Loading branch information
bcribas committed Apr 1, 2021
1 parent c0980d6 commit 25bb5e6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pqsortsimple.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright(C) 2020, Bruno César Ribas <bruno.ribas@unb.br>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2.1 of the GNU Lesser General Public License
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include "pqsortsimple.h"
#include "ordenacaomacros.h"
#include "priority-queue.h"

void pqsortsimple(Item *v, int l, int r)
{
int k;
PQinit((r-l+1));
for(k=l;k<=r;k++) PQinsert(v[k]);
for(k=r;k>=l;k--) v[k]=PQdelmax();
}
23 changes: 23 additions & 0 deletions pqsortsimple.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright(C) 2020, Bruno César Ribas <bruno.ribas@unb.br>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2.1 of the GNU Lesser General Public License
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef __PQsortsimple__
#define __PQsortsimple__
#include "ordenacaomacros.h"

void pqsortsimple(Item *,int, int);

#ifdef __pqsortonly__
#define sort(v,l,r) pqsortsimple(v,l,r)
#endif

#endif

0 comments on commit 25bb5e6

Please sign in to comment.