Tags » ADT

C code for queues


#include <stdio.h>
#include <stdlib.h>

struct _link {
    struct _link *next;
    int data;
};

struct _queue {
    struct _link *front, *rear;
};
#define qempty(Q) ((Q)->front == NULL)

void qput(struct _queue *Q, int data)
{
    struct _link *t = (struct _link *) malloc(sizeof(struct _link));
    t->data = data;    
    t->next = NULL;
    if (qempty(Q)) {
        Q->front = Q->rear = t;
    } else {
        Q->rear->next = t;
        Q->rear = t;
    }
}

struct _link *qget(struct _queue *Q)
{
    struct _link *t;
    if (qempty(Q)) return NULL;
    t = Q->front;
    Q->front = Q->front->next;
	if (qempty(Q)) Q->rear = NULL;
    return t;
}

void qshow(struct _queue *Q)
{
    struct _link *list = Q->front;
    if (qempty(Q)) {
        printf("queue is empty\n");
            return;
    }
    while (list) {
        printf("data => %d\n", list->data);
        list = list->next;
    }
}

int main(int argc, char **argv)
{
    int i;
    struct _link *t;
    struct _queue q;
    q.front = q.rear = NULL;
    for (i = 0; i < 4; i++) {
        qput(&q, i);
    }
    qshow(&q);
    while (!qempty(&q)) {
        t = qget(&q);
        printf("t->data = %d\n", t->data);
        free(t);
    }
    qshow(&q);
}
Adt

Murphy's Law

I wanted to write letter, instead of sending an email, but I can’t find a pen.  After 10 minutes, I find the pen, only for it to be dry. 360 more words

Getting Started with Android Development: Downloading the Android ADT Bundle

So you’ve decided to join the ranks of Android developers, eh? Good decision.

There are a couple of things that need to be set up before you’re able to get started: 182 more words

Adt

C code for stacks


#include <stdio.h>
#include <stdlib.h>

struct _link {
    struct _link *next;
    int data;
};

void push(struct _link *head, int data)
{
    struct _link *t = (struct _link *) malloc(sizeof(struct _link));
    t->data = data;
    t->next = head->next;
    head->next = t;
}

int top(struct _link *head)
{
    struct _link *l = head->next;
    int data = -1;
    if (l) {
        data = l->data;
    }
    return data;
}

int pop(struct _link *head)
{
    struct _link *l = head->next;
    int data;
    if (l) {
        data = l->data;
        head->next = l->next;
        free(l);
    }
    return data;
}

void show(struct _link *head)
{
    struct _link *list;
    if (!head) return;

    list = head->next;
    if (!list) {
        printf("list empty..\n");
        return;
    }
    printf("\n");
    while (list) {
        printf("x => %d\n", list->data);
        list = list->next;
    }
}

int main(int argc, char *argv[])
{
    int data;
    struct _link stack;
    stack.next = NULL;
    push(&stack, 1);
    push(&stack, 2);
    push(&stack, 3);
    push(&stack, 4);
    push(&stack, 5);
    show(&stack);
    data = pop(&stack);
    printf("popped: %d\n", data);
    show(&stack);
    data = top(&stack);
    printf("topped: %d\n", data);
    return 0;
}
Adt

ADT Customer Service Jobs

Customer Service Jobs
ADT is committed to hiring team members who are passionate about providing exceptional customer service – people who understand the importance of customer satisfaction and what it means to their career development. 55 more words

Job &amp; Career Opportunities

6 Brands That Will Have You Rethinking Your Social Media Strategy

It’s no secret; social media marketing isn’t as straightforward as it used to be and consumers are getting more socially savvy by the moment. Today’s consumer no longer just hopes, but expects their favorite brands to continue to offer them new and innovative ways to engage socially. 1,680 more words

Marketing

Malaysia, and what it's like to fly through there today

I will never remember being in Malaysia this week for playing in a pollution-shortened golf tournament, for hitting a shot that was a revolution away from a double-eagle, or for the putts I made and greens I missed. 1,868 more words

Blog Posts