Posts

Showing posts from May, 2022

Queue - Data Structures

Image
  Queue is the data structure that is similar to the queue in the real world. A queue is a data structure in which whatever comes first will go out first, and it follows the FIFO (First-In-First-Out) policy. Queue can also be defined as the list or collection in which the insertion is done from one end known as the   rear end   or the   tail   of the queue, whereas the deletion is done from another end known as the   front end   or the   head   of the queue. The real-world example of a queue is the ticket queue outside a cinema hall, where the person who enters first in the queue gets the ticket first, and the last person enters in the queue gets the ticket at last. Similar approach is followed in the queue in data structure. Now, let's move towards the types of queue. Types of Queue There are four different types of queue that are listed as follows - Simple Queue or Linear Queue Circular Queue Priority Queue Double Ended Queue (or Deque) Let's discuss each of the type of queue

Stack - Data Structure

Image
  A Stack is a linear data structure that follows the   LIFO (Last-In-First-Out)   principle. Stack has one end, whereas the Queue has two ends ( front and rear ). It contains only one pointer   top pointer   pointing to the topmost element of the stack. Whenever an element is added in the stack, it is added on the top of the stack, and the element can be deleted only from the stack. In other words, a   stack can be defined as a container in which insertion and deletion can be done from the one end known as the top of the stack. Some key points related to stack It is called as stack because it behaves like a real-world stack, piles of books, etc. A Stack is an abstract data type with a pre-defined capacity, which means that it can store the elements of a limited size. It is a data structure that follows some order to insert and delete the elements, and that order can be LIFO or FILO. Working of Stack Stack works on the LIFO pattern. As we can observe in the below figure there are five

Java - Swing

  Swing  is a Java Foundation Classes JFC] library and an extension of the Abstract Window Toolkit [AWT]. Swing offers much-improved functionality over AWT, new components, expanded components features, excellent event handling with drag and drop support. Introduction of Java Swing Swing has about four times the number of User Interface [U1] components as AWT and is part of the standard Java distribution. By today’s application GUI requirements, AWT is a limited implementation, not quite capable of providing the components required for developing complex GUI’s required in modern commercial applications. The AWT component set has quite a few bugs and really does take up a lot of system resources when compared to equivalent Swing resources. Netscape introduced its Internet Foundation Classes [IFC] library for use with Java. Its Classes became very popular with programmers creating GUI’s for commercial applications. Swing is a Set Of API ( API- Set Of Classes and Interfaces ) Swing is Pro

Exception Handling

  Exception Handling  in Java is one of the effective means to handle the runtime errors so that the regular flow of the application can be preserved. Java Exception Handling is a mechanism to handle runtime errors such as ClassNotFoundException, IOException, SQLException, RemoteException, etc. Exception  is an unwanted or unexpected event, which occurs during the execution of a program i.e at run time, that disrupts the normal flow of the program’s instructions. Exceptions can be caught and handled by the program. When an exception occurs within a method, it creates an object. This object is called the exception object. It contains information about the exception such as the name and description of the exception and the state of the program when the exception occurred. Major reasons why an exception Occurs Invalid user input Device failure Loss of network connection Physical limitations (out of disk memory) Code errors Opening an unavailable file Errors  represent irrecoverable condit