Posts

Showing posts from December, 2015

Adobe Interview Questions - Finding first repeating elements in a given array

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Memory_understanding {     class Reapting_elements     {         public void getfirstrepeatingelements(int[] arr)         {             int min = -1;             int element=0;             HashSet<int> set = new HashSet<int>();             for (int i = arr.Length-1; i >= 0; i--)             {                 if(set.Contains(arr[i]))                 {                     min=i;                     element=arr[i];                 }                 else                 {    set.Add(arr[i]);}             }             if (min == -1)                 Console.WriteLine("No Repeating ELements!!!");             else                 Console.WriteLine("Minimum repeating element" + element);         }     }     class Program     {         public static void Main_()         {             Reapti

Cerner Interview Question -- Implement Binary Search Tree

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Memory_understanding {     class Node     {         private char val;         public char Val { get; set; }         public Node leftChild;         public Node rightChild;         public Node(char value)         {             this.Val= value;             this.leftChild = null;             this.rightChild = null;         }      }     class BST_Operations     {         Node root;         public BST_Operations()         {             root = null;         }         private void construct(char val,ref Node node)         {             if (node==null)             {                 Node temp= new Node(val);                 node=temp;                 return;                             }             if ((int)node.Val >= (int)val)             {                 construct(val,ref node.leftChild);                 return;    

Tesco Interview Questions

Tesco Interview Questions using System; using System.Collections.Generic; namespace Memory_understanding {     public class UserMainCode     {         //Assume following return types while writing the code for this question.         public static int output1;         public static int letter(string input1)         {             int sum = 0;             char[] arra = input1.ToCharArray();             for (int i = 0; i < arra.Length; i++)             {                 char char_a = arra[i];                 int pos = getPosition(char_a);                 sum = sum + fib(pos);             }             output1 = sum;             return output1;         }         public static int fib(int n)         {             if (n == 0)                 return 0;             if (n == 1)                 return 1;             else                 return fib(n - 1) + fib(n - 2);         }         public static int getPosition(char n)         {            

LinkedList Representation

Linked List Representation using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Memory_understanding {     public class Node_     {         public Node_ next;         public object data;     }     public class LinkedList     {         private Node_ head;         public void printAllNodes()         {             Node_ current=head;             while(current !=null)             {                 Console.WriteLine(current.data);                 current=current.next;             }         }         public void AddFirst(Object data)         {             Node_ toadd= new Node_();             toadd.next=head;             toadd.data=data;             head=toadd;         }         public void AddLast(Object data)         {             if(head == null)             {                 head = new  Node_();                 head.data=data;                 head.next=null;        

Adobe Interview Questions --FullStackImplementation

Adobe Interview Questions Full Stack Implementation using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Memory_understanding {     class fullStack     {         int[] arry;         int top;         int[] stack;         int a;         public fullStack()         {             arry = new int[7];             stack = new int[7];             top = -1;         }         public void push(int element)         {             if (!isfull())             {                 arry[top+1] = element;                 if (top == -1)                 {                     stack[top+1] = element;                 }                 else                 {                     if (stack[top] > element)                     {                         stack[top+1] = element;                     }                     else                     {                         stack[top+1] = stack[top];    

Interfaces

 Interfaces  The below note is taken from the link below . By Vikram Chaudhary -->http://www.dotnetforall.com/why-do-we-use-interfaces-in-csharp/ Extensibility Implementation Hiding Accessing object through interfaces Loose Coupling. Before stating the discussion about the code, I would like to take you through the various components of the project as shown in the following figure InterfaceUtilization  is the client which would be using the interface components to achieve the functionality for the task. The client only contains the references for the Interfaces and Factory namespaces. Car and Driver are the assemblies which contains  the classes which implements the ICar and IDriver interfaces from the Interfaces namespace. These classes are the entities whose instances would be used to achieve the desired functionality. Interfaces is the namespace which contains the contracts or interfaces which would be in turn be implemented by the individual classes(in our