Tuesday 29 December 2020

printing the matrix in spiral format in c

#include<stdio.h>
#include<string.h>
int main() 
{
    int n,i,j,r=0,co=1,c=0,nr=0,nc=0;
    scanf("%d",&n);
    int mat[n][n],nd=n;
    while(n>=1)
    {
        for(i=1;i<n;i++)
            mat[r][c++]=co++;

        for(i=1;i<n;i++)
            mat[r++][c]=co++;

        for(i=1;i<n;i++)
            mat[r][c--]=co++;

        for(i=1;i<n;i++)
            mat[r--][c]=co++;

        n=n-2;
        nr++;
        nc++;
        r=nr;
        c=nc;
    }
    if(nd%2 != 0)
        mat[--nr][--nc]=co;

    for(i=0;i<nd;i++)
    {
        for(j=0;j<nd;j++)
            printf("%3d ",mat[i][j] ); 
        printf("\n");
    }

input 

6

output:
  1   2     3   4    5     6 
 20  21  22  23  24   7 
 19  32  33  34  25   8 
 18  31  36  35  26   9 
 17  30  29  28  27  10 
 16  15  14  13  12  11

Monday 28 December 2020

Hacker Rank Append and Delete solution in c

Problem:

https://www.hackerrank.com/challenges/append-and-delete/problem

Solution:

#include<stdio.h>

#include<string.h>

int main()
{
    char s[101],t[101];
    int k;
    scanf(" %s",s);
    scanf(" %s",t);
    scanf("%d",&k);
    int ls=strlen(s);
    int lt=strlen(t),i,ans;
    for(i=0;s[i]!='\0'&&t[i]!='\0';i++)
    {
        if(s[i]!=t[i])
            break;
    }
    ans=ls-i+lt-i;
        
    if(ans ==k||(ans < k && ans%2 == k%2)||k>=ls+lt)
        printf("Yes");
    else
        printf("No");
    
}

consider this testcase
y
yu
2
Here we can perform only one operation that is appending u
but given k is 2
so for this test case output must be No
so this is taken care by the condition
number of operations required and k must be even
as delete and append are two operations.

Also when k>=ls+lt, we can remove entire s string and append t string
as we can delete an empty string as many times as we like..so when k>=ls+lt,
output is always "YES"


Friday 18 December 2020

John and GCD list Hacker Rank solution in C

Problem:
https://www.hackerrank.com/challenges/john-and-gcd-list/problem

Explanation:
GCD(B[1],B[2]) =A[1] that is A[1] divides B[2]
GCD(B[2],B[3]) =A[2] that is A[2] also divides B[2]

so B[2] must be divisible by both A[1] and A[2].
as LCM of A[1],A[2] will be divisible by both A[1] and A[2].
Therefore B[2] must be a multiple of LCM(A[1],A[2])
Since in the question, they wanted minimum value of B[2]
So, B[2] = LCM(A[1],A[2])


#include<stdio.h>
int gcd(int,int);
int lcm(int,int);
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,i;
        scanf("%d",&n);
        int a[n];
        for(i=0 ; i<n ; i++)
            scanf("%d",&a[i]);
        printf("%d ",a[0]);
        for(i=0 ; i<n-1 ; i++)
        {
            if(a[i+1] >a[i])
                printf("%d ",lcm(a[i+1],a[i]));
            else
                printf("%d ",lcm(a[i],a[i+1]));
        }
        printf("%d\n",a[n-1]);        
    }
    return 0;
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int lcm(int a, int b)
{
    return (a*b)/gcd(a,b);
}

Tuesday 15 December 2020

Sum The Series Problem Code: SUM1 codechef solution in c

https://www.codechef.com/problems/SUM1 

Explanation:



In the Question, it is mentioned to do %1000000007, to ensure the answer will always a number from 0 to 1000000006 

As n can take a value upto 10^16 in the question and n^2 cannot fit in even long long int, we cannot do n*n and then apply %1000000007

So we cannot do (n*n)%1000000007 so we do like this

((n%1000000007)*(n%1000000007))%1000000007

According to modular arithmetic (a*b)%m = ((a%m)*(b%m))%m

Here is the solution:

#include<stdio.h>

#define MOD 1000000007

int main() 

{

int t;

scanf("%d",&t);

while(t--)

{

    long long int n;

    scanf("%lld",&n);

    printf("%lld\n",(((n%MOD)*(n%MOD))%MOD));

}

return 0;

}

Printing Pattern Using Loops Hacker Rank Solution in C

https://www.hackerrank.com/challenges/printing-pattern-2 

Solution

#include <stdio.h>

int main() 

{

    int n,d,min;

    scanf("%d", &n);

  d=2*n-1;

    for(int i=1;i<=d;i++)

    {

        for(int j=1;j<=d;j++)

        {

            if(i<j)

                min=i-1;

            else

                min=j-1;

            if(min>d-j)

                min=d-j;

            if(min>d-i)

                min=d-i;

            printf("%d ",n-min);

        }

        printf("\n");

    }

    return 0;

}

Tuesday 17 November 2020

Easy Problem Links in Hacker Earth

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/jump-out-34/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/easy-multiple/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/good-string-3/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/title-abhi-socha-nahi/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/palindromic-numbers-7/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/step-up-0aa9708f/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/cheapest-subarray-d628cb65/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/brick-and-building-26cc28f2/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/techfest-and-group-photo-06dfebc0/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/easy-multiples/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/counting-rr/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/prime-string-598/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/roys-life-cycle-44/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/fredo-and-game/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/roys-life-cycle/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/recursive-sums/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/coin-game-3-1762eeeb/

Monday 9 November 2020

python program to store the first 100 prime numbers excluding 2 in an array using sieve of Eratosthenes

 

pf=[1]

def gp(n):

               pr = [1 for i in range(n + 1)]

               p = 2

               while (p * p <= n):

                              if (pr[p] == 1):

                                             for i in range(p * 2, n + 1, p):

                                                            pr[i] = 0

                              p = p + 1

               pr[0]= 0

               pr[1]= 0

               pr[2]= 0

 

               for p in range(n + 1):

                              if pr[p]:

                                             pf.append(p)

gp(541)

print(pf)

Sunday 8 November 2020

Replace every element of the array by product of all other elements

Replace every element of the array by product of all other elements

 For example : Consider an array as shown below


If you want to implement the above logic using O(n) space, you can do it only using recursion.

Solution can be found at

https://www.techiedelight.com/replace-element-array-product-every-element-without-using-division-operator/


Recursion tree is as follows




Wednesday 21 October 2020

Windows Programming MCQs

 

Windows Programming MCQs

1.      ________ enables one to explore the resources of Windows:



a.       API

b.      CPP

c.       MFC

d.      ATL



2.      Which application  we will use to make program more portable:



a.       WindowsAPI

b.      WindowApp

c.       MFC

d.      None of these



3.      The Win32API supports:



a.       16-bit Windows

b.      32-bit Windows

c.       64-bit Windows

d.      All of these



4.      Win32Program utilizes a central function called:



a.       Main

b.      App

c.       WinMain

d.      None of these



5.      The arguments of the WinMain() function are mandatory and it communicate with:



a.       Operating System

b.      Hardware

c.       Kernel

d.      None of these



6.      Which is the parameter of the WinMain():



a.       HInstance

b.      hPrecInstance

c.       LPSTR lpCmdLine

d.      Int nCmdShow

e.       All of these



7.      Which is used to install and configure the service application:



a.       Administration and Management

b.      Networking

c.       Archie

 

d.      Gopher



8.      ______ is done by pressing the restart button while the computer is on:



a.       Cold boot

b.      Warm boot

c.       Both a and b

d.      None of these



9.      ______ is done by pressing the power switch when it is turned off:



a.       Cold boot

b.      Warm boot

c.       Both a and b

d.      None of these



10.  What is the full form of BIOS-ROM:

a.       Basic Input Output System – Read Only Memory

b.      Binary Input Output System – Read Only Memory

c.       Binary Input Output System – Random Only Memory

d.      Basic Input Output System – Random Only Memory

 

 

11.  VRML stands for:

a.       Virtual Reality Model Language

b.      Virtual Reality Modeling Language

c.       Virtual Read-only Modeling Language

d.      Virtual Reality Mode Language

12.  HTML stands for:



a.       Hyper Text Meta Language

b.      High Text Markup Language

c.       Hyper Text Markup Language

d.      High Test Markup Language



13.  WPF stands for:

a.       Windows Presentation Function

b.      Windows Presentation Foundation

c.       Windows Procedure Foundation

d.      None of these

14.  WCF stands for:

a.       Windows Computer Foundation

b.      Windows Communication Foundation

c.       Windows Central Foundation

d.      None of these

15.  RPC stands for:



a.       Remote Presentation Call

b.      Radio Presentation Call

c.       Remote Procedure Call

d.      None of these



16.  SNMP stands for:

a.       Secure Network Management Protocol

b.      Simple Network Management Protocol

c.       Secured Network Management Procedure

d.       Simple Network Management Procedure

17.  HTTP stand for:

a.       Hyper Text Tele Protocol

b.      Hyper Text Transfer Protocol

c.       Hyper Text Transfer Procedure

d.      Hyper Tele Transfer Procedure

18.  FTP stands for:



a.       File Transaction Protocol

b.      File Transfer Protocol

c.       Format Transfer Protocol

d.      Formal Transfer Protocol



19.  DNS stands for:



a.       Domain Network System

b.      Domain Name System

c.       Data Name System

d.      Data Name Service



20.  BITS stands for:

a.       Binary Intelligent Transfer Service

b.      Background Intelligent Transfer Service

c.       Background Integrated Transfer Service

d.      Binary Integrated Text Service

21.  WWW stands for:



a.       World Web Wide

b.      World Wide Web

c.       Web Wide World

d.      None of These



22.  XML stands for:

a.       eXtensible Markup Language

b.      eXtra Markup Language

c.       eXtensible Mode Language

d.      None of these

23.  URI stands for:

a.       Universal Resource Identifier

b.      Uniform Resource Identifier

c.       Uniform Resource Identification

d.      Universal Resource Identification

24.  TCP/IP stands for:

a.       Transfer Control Protocol / Internet Protocol

b.      Transmission Control Protocol / Internet Protocol

c.       Transfer Configuration Protocol / Internet Protocol

d.      None of these

25.  CSP stands for:

a.       Cryptographic System Provider

b.      Cryptographic Service Providers

c.       Computer Service Provider

d.      Cryptographic Service Protocol

26.  _________ is a standard by which internet names are translated to their corresponding IP addresses:



a.       DSP

b.      DSW

c.       DNS

d.      DLL



27.  ________ is supported by TCP/IP client accessing Web document on Web server:



a.       Web Browsers

b.      Operating System

c.       Windows

d.      None of these



28.  What is return type of InitInstance:



a.       bool

b.      int

c.       char

d.      double



29.  In Win32 which function is used to create application:



a.       WinMain

b.      WinApp

c.       WinAPI

d.      None of these



30.  Security protects the data from:



a.       Authorized accessing

b.      Unauthorized accessing

c.       Administrator accessing

d.      None of these



31.  Which function handle the key container:



a.       CryptoAPI

b.      CryptAcquireContext

c.       CAPICOM

d.      CryptoGraphics



32.  The MFC library is a predefined set of:



a.       Data types

b.      Function

c.       Classes

d.      Constant

e.       All of these



33.  Which class is used to display something on screen:



a.       CWinApp

b.      MFC

c.       CWinAPI

d.      None of these



34.    Which function is provide by CWinApp to display something on screen:



a.       Start()

b.      Load()

c.       Close()

d.      InitApplication()



35.  Where the fundamental  classes of MFC are declared:



a.       afxwin.h

b.      include.h

c.       graphics.h

d.      conio.h



36.  What is included by frame of window:



a.       Location

b.      Dimension

c.       Borders

d.      All of these



37.  Which class is used by MFC to create the frame:



a.       CMainFrame

b.      CFrameWnd

c.       CMainWnd

d.      None of these



38.  Which class is used to create a Window frame:



a.       CFrameWnd

b.      CMainFrame

c.       CMainWnd

d.      None of these



39.   Which function is associated with window frame:



a.       InitApp()

b.      Stop()

c.       Destroy()

d.      Create()



40.  Which is the base class of CWinApp:



a.       CWinThread

b.      CWin

c.       CWin_Tread

d.      CThread



41.  Which function is called to display the frame in resultant window:



a.       CloseWindow()

b.      ShowWindow()

c.       DeleteWindow()

d.      None of these



42.  Which file is required to export the DLL function:



a.       A.def

b.      A.dll

c.       A.exe

d.      None of these



43.  Which function is used to create DLL files:****



a.       DllMain

b.      DefMain

c.       Main

d.      Void_main



44.   Which keyword is used to declare the variable and function to specify the external link:



a.       extern

b.      void

c.       this

d.      new



45.  Which macro is used to handle the command message:



a.       ON_COMMAND

b.      ON_LBUTTONDOWN

c.       ON_RBUTTONDOWN

d.      ON_LBUTTONDBLCLK



46.  Which class is used to handle the windows message and control notification:



a.       CWnd

b.      CFrameWnd

c.       CMDIFrameWnd

d.      CView



47.   Which classes are included by CWnd class:



a.       CFrameWnd

b.      CMDIFrameWnd

c.       CView

d.      CMDIChildWnd

e.       All of these



48.  MVC stands for:

a.       Model View Controller

49.  Which  key events are identified by wParam:



a.       Shift

b.      Ctrl

c.       Both a and b

d.      None of these



50.  Which class is provided by MFC library:



a.       CScrollView

b.      CView

c.       CFrame

d.      None of these



51.  Web browser can access:



a.       Client computer

b.      Application Programs

c.       Web Pages

d.      All of these



52.  Which protocol is supported by web browser:



a.       TCP/IP

b.      IP

c.       TCP

d.      All of these



53.  A browser can support:



a.       Hyper Text

b.      Images

c.       Sound Files

d.      Flash Animations

e.       All of these



54.  Security is implemented by:



a.       Crypto API

b.      Cryptographic Service Providers

c.       CAPICOM

d.      All of these



55.  Security protects data from:



a.       Fire

b.      Flood

c.       Unauthorized access

d.      Authenticated user



56.  CSP contains a key that is stored in….



a.       Web Browser

b.      Text files

c.       Encrypted files

d.      Key Database



57.  The parameters for Create() function are:



a.       LPCTSTR lpszClassName

b.      LPCTSTR lpszWindowName

c.       DWORD dwStyle

d.      lpszMenuName

e.       All of these



58.  Which function is essential for DLL files:



a.       DllMain

b.      DefMain

c.       VoidMain

d.      Main



59.  Parameter contains:



a.       ID

b.      wParam

c.       lParam

d.      All of these



60.  Which is the Scroll message handler:



a.       WM_VSCROLL

b.      WM_HSCROLL

c.       Both a and b

d.      None of these



61.  Which is the base class for Bitmap:



a.       CBitmap

b.      CView

c.       CScrollView

d.      None of these



62.  Which function load bitmap image into CBitmap object:



a.       LoadBitmapW

b.      StartBitmap

c.       DeleteBitmap

d.      None of these



 

63.  Which function is used to get size of scrolls:

a.       GetDeviceScrollSizes()

64.  Which is the parent of all MFC view classes:



a.       CDocView

b.      CTableView

c.       CScrollView

d.      CView



65.  The nMapMode argument holds a mapping mode that is:



a.       MM_TEXT

b.      MM_HIMETRIC

c.       MM_TWIPS

d.      MM_HIENGLISH

e.       All of these



66.   _______ handles the connections from client and can provide several independent screens:



a.       Client

b.      Server

c.       Both a and b

d.      None of these



67.  What is required to provide the control for X server:



a.       Client’s hostname

b.      IP address

c.       Both a and b

d.      None of these



68.  By which program we can manipulate the access control list:



a.       Xhost

b.      Xhost+hostname

c.       Xhost-hostname

d.      None of these



69.  We can add a host to the list with:



a.       Xhost

b.      Xhost+hostname

c.       Xhost-hostname

d.      None of these



70.  We can remove host from the list with:



a.       Xhost

b.      Xhost+hostname

c.       Xhost-hostname

d.      None of these



71.  DECNET stands for:

a.       Digital Equipment Corporation Networking

72.  X contains:



a.       X Protocol

b.      X Display Server

c.       X Client

d.      Xlib routines



e.       All of these

73.  X was developed to create a platform-independent network-based:



a.       A complete OS

b.      Graphical User environment

c.       Both a and b

d.      None of these



74.  The X window protocol has the server that provides the ________ windowing mechanism:



a.       Advance basic

b.      Advance

c.       Basic

d.      None of these



75.  Server handles the connections from ________ and can provides several independent screens:



a.       Other servers

b.      Clients

c.       Internet

d.      None of these



76.  The function of the X Window is:



a.       Establish a connection with the X server

b.      Create a window

c.       Create X resources

d.      Wait, detect and perform event

e.       All of these



77.  The X windows system is GUI and is entirely based on:



a.       Microsoft Windows

b.      Macintosh Operating System

c.       Both a and b

d.      None of these



78.  The X-Term terminal emulator and the user interface that supports:



a.       Window

b.      Mouse

c.       Keyboard

d.      All of these



79.  It is used to listen to the network connections at a specific port is called:



a.       X Client

b.      X Server

c.       X Window

d.      X application



80.  X Server supports:



a.       Single Window Mode

b.      Multiple Window Mode

c.       Both a and b

d.      None of these



81.  Which network protocol is supported by X:



a.       TCP/IP

b.      DECNET

c.       STREAMS

d.      All of these



82.  Which variable is used to determine where the x server is located:



a.       Display

b.      Search

c.       Both a and b

d.      None of these



83.  What is the name of function that is added for WM_KEYDOWN:



a.       OnKeyDown

b.      OnKeyUp

c.       Both a and b

d.      None of these



84.  Which is the parameters / arguments of OnKeyDown function:



a.       nChar

b.      nRepCnt

c.       nFlags

d.      All of these



85.  Which function is used to set cursor:

a.       SetCursor

86.  In OnKeyDown which argument represent the number of times of key pressing:



a.       nChar

b.      nRepCnt

c.       nFlags

d.      None of these



87.   Which argument keeps a combination flag that checks whether key is being pressed at the same time with the other keys:



a.       nChar

b.      nRepCnt

c.       nFlags

d.      None of these



88.  The Class Wizard is use function for WM_SETCURSOR message:

a.       OnSetCursor

89.  To register your own window class containing the desired mouse pointer by using:



a.       AfxRegisterClass()

b.      AfxRegisterWndClass()

c.       Both a and b

d.      None of these



90.  Which class refers to the co-ordination point of screen:

a.       CPoint

91.  In which namespace cursor are stored:

a.       Cursor namespace

92.  Which is the property of the panel control:



a.       Location

b.      Size

c.       Border Style

d.      Cursor

e.       All of these



93.  Which is the protective mechanism that lies between the computer network and the Internet to protect from malfunctions and network-based security threats:



a.       Firewall

b.      Archie

c.       Finger

d.      Active attacks



94.  Which indicator represents the position of the mouse on a screen:



a.       Cursor

b.      Mouse

c.       Keyboard

d.      None of these



95.  Which program is used for searches files anywhere on the network by the filename:



a.       Archie

b.      Firewall

c.       Finger

d.      Active attacks

 

Fuzzy sets MCQs

 

CBSE NET Fuzzy sets Questions and Answers

Check the link below for more such questions
http://ugcnetsolved-computerscience.blogspot.in/?view=flipcard

1. How to denote a fuzzy set?
IF X is the universe of discourse and x is a particular element of X, then a fuzzy set A defined on X may be written as a collection of ordered pairs:
A={(x,µA(A))}, x belongs to X
The pair (x, µA(A)) is called a singleton.
In crisp sets, a singleton is simply the element x by itself.
In fuzzysets, a singleton is composed of two terms: x and µA(x).
A singleton is also written as µA(x)/x. That is by putting the membership function first followed by the ‘/’symbol and is used to separate the function from x.
Singletons whose membership to a fuzzy set is 0 may be omitted.

2. Union of two fuzzy sets
µAUB(x) = µA(x) V µB(x) = max(µA(x), µB(x))

3. Intersection of two fuzzy sets
µA Intersection B(x) = µA(x) ^ µB(x) = min(µA(x), µB(x))

4. Complement of a fuzzy set
The complement of a fuzzy set A is a new fuzzy set A Complement, containing all the elements which are in the universe of discourse but not in A, with the membership function
Complement of µA(x) = 1 - µA(x)

5. Height of a fuzzy set
The height of a fuzzy set is the highest membership value of the membership function:
Height(A) = max µA(xi)
A fuzzy set with height 1 is called a normal fuzzy set.
In contrast, a fuzzy set whose height is less than 1 is called a subnormal fuzzy set.

6. α-cut of a fuzzy set
α-cut of a fuzzy set A denoted as Aα, is the crisp set comprised of the elements x of a universe of discourse X for which the membership function of A is greater than or equal to α.

Solved problems from various NET papers.
JUNE 2012 – PAPER III Q.No 6
6. If two fuzzy sets A and B are given with membership functions μA(x) = {0.2, 0.4, 0.8, 0.5, 0.1} μB(x) = {0.1, 0.3, 0.6, 0.3, 0.2} Then the value of μ ––– will be A∩B
(A) {0.9, 0.7, 0.4, 0.8, 0.9}
(B) {0.2, 0.4, 0.8, 0.5, 0.2}
(C) {0.1, 0.3, 0.6, 0.3, 0.1}
(D) {0.7, 0.3, 0.4, 0.2, 0.7}
Ans:-A
Explanation:- The fuzzy intersection of two fuzzy sets A and B on universe of discourse X: μA∩B(x) = min [μA(x), μB(x)] , where xXBut here in the question, they are asking for complement of A intersection B and so the answer would be 1-min[A(x),B(x)].
The minimum of 0.2 and 0.1 will be 0.1, and 1-0.1 will be 0.9
The second value is min(0.4,0.3)=0.3 and 1-0.3=0.7
The third value is min(0.8,0.6)=0.6 and 1-0.6=0.4
The fourth value is min(0.5,0.3)=0.3 and 1-0.3=0.7
The last value is min(0.1,0.2)=0.1 and 1-0.1=0.9
The only option which has got the values 0.9,0.7,0.4,0.7 and 0.9, although the fourth value is given as 0.8 instead of 0.7 is option A.
So the answer is option A.

DECEMBER 2012 – PAPER III Q.No 13
13. Consider a fuzzy set A defined on the interval x=[0,10] of integers by the membership function.
µA(x) = x / x+ 2
α cut corresponding to α = 0.5 will be
(A) { 0,1,2,3,4,5,6,7,8,9,10}
(B) {1,2,3,4,5,6,7,8,9,10}
(C) {2,3,4,5,6,7,8,9,10}
(D) { }
Ans:- C
Explanation:-
In the fundamentals, refer to the answer given for question no. 6 regarding α-cut.
α-cut of a fuzzy set A denoted as Aα, is the crisp set comprised of the elements x of a universe of discourse X for which the membership function of A is greater than or equal to α.
Given, x = In the range [0,10]
Membership function = x/x+2
Calculate the value of membership function for the interval from 0 to 10, substituting in the formula x/x+2.
µA(0) = 0 / 0+ 2 = 0

µA(1) = 1 / 1+ 2 = 0.33

µA(2) = 2 / 2+ 2 = 0.5

µA(3) = 3 / 3+ 2 = 0.6

µA(4) = 4 / 4+ 2 = 0.66

µA(5) = 5 / 5+ 2 = 0.71

µA(6) = 6 / 6+ 2 = 0.75

µA(7) = 7 / 7+ 2 = 0.77

µA(8) = 8 / 8+ 2 = 0.8

µA(9) = 9 / 9+ 2 = 0.81

µA(10) = 10 / 10+ 2 = 0.83

α= 0.5. We have to find the corresponding α-cut,

That will be a crisp set, having those values of x, for which the membership function is returning a value of 0.5 or above.

µA(2) = 0.5 and all the values of x above 2 is getting a value greater than 0.5. So the crisp set will contain the following values.

{ 2,3,4,5,6,7,8,9,10}.

So the correct answer is C.


DECEMBER 2013 – PAPER III Q.No 28
28. If A and B are two fuzzy sets with membership functions μA(x) = {0.2, 0.5, 0.6, 0.1, 0.9} μB(x) = {0.1, 0.5, 0.2, 0.7, 0.8} Then the value of μA ∩B

will be

(A) {0.2, 0.5, 0.6, 0.7, 0.9}

(B) {0.2, 0.5, 0.2, 0.1, 0.8}

(C) {0.1, 0.5, 0.6, 0.1, 0.8}

(D) {0.1, 0.5, 0.2, 0.1, 0.8}

Ans:-D

Explanation:-

Intersection of two fuzzy sets

µA ∩B (x) = µA(x) ^ µB(x) = min(µA(x), µB(x))

μA(x) = {0.2, 0.5, 0.6, 0.1, 0.9}

μB(x) = {0.1, 0.5, 0.2, 0.7, 0.8}

μA ∩B={0.1,0.5,0.2,0.1,0.8}

So, the correct answer is D.


29. The height h(A) of a fuzzy set A is defined as h(A) =sup A(x) where x belongs to A. Then the fuzzy set A is called normal when

(A)h(A)=0

(B)h(A)<0

(C)h(A)=1

(D)h(A)<1

Ans:- C

Explanation:-

Explanation:- The height of a fuzzy set is the highest membership value of the membership function: Height(A) = max µA(xi)

A fuzzy set with height 1 is called a normal fuzzy set.

In contrast, a fuzzy set whose height is less than 1 is called a subnormal fuzzy set. So, according to the above rule, the fuzzy set A is called normal when h(A)=1.

So, the correct answer is 1.


JUNE 2013 – PAPER III Q.No 74
74. If A and B are two fuzzy sets with membership functions μA(x) = {0.6, 0.5, 0.1, 0.7, 0.8} μB(x) = {0.9, 0.2, 0.6, 0.8, 0.5}

Then the value of μ Complement AB(x) will be

(A) {0.9, 0.5, 0.6, 0.8, 0.8}

(B) {0.6, 0.2, 0.1, 0.7, 0.5}

(C) {0.1, 0.5, 0.4, 0.2, 0.2}

(D){0.1,0.5,0.4,0.2,0.3}

Ans:- C

Union of two fuzzy sets

µAUB
(x) = µA(x) V µB(x) = max(µA(x), µB(x))

μA(x) = {0.6, 0.5, 0.1, 0.7, 0.8}

μB(x) = {0.9, 0.2, 0.6, 0.8, 0.5}

µAUB(x) = {0.9,0.5,0.6,0.8,0.8}

Complement of µAUB(x)={0.1,0.5,0.4,0.2,0.2}

So, the correct answer is C.


JUNE 2014 – PAPER III Q.No 7,8 7. Given U = {1, 2, 3, 4, 5, 6, 7} A = {(3, 0.7), (5, 1), (6, 0.8)} then

~ A will be : (where ~ →complement)

(A) {(4, 0.7), (2, 1), (1, 0.8)}

(B) {(4, 0.3), (5, 0), (6, 0.2) }

(C) {(1, 1), (2, 1), (3, 0.3), (4, 1), (6, 0.2), (7, 1)}

(D) {(3, 0.3), (6.0.2)}

Ans:- C

Explanation:-

Complement of a fuzzy set

The complement of a fuzzy set A is a new fuzzy set A Complement, containing all the elements which are in the universe of discourse but not in A, with the membership function

Complement of µA(x) = 1 - µA(x)

Complement of a fuzzy set A is a new fuzzy set A complement. Since it is a fuzzy set, there will be two members in a singleton. The first member will be all the elements which are in the universe of discourse but not in A. The membership function will be 1- µA(x).

So, the complement of A will be

{(1,1),(2,1),(3,0.3),(4,1),(6,0.2),(7,1)}

The first is (1,1). The first 1 is in U but not in A, so it should be added in the complement. The second 1 is because the membership function is 1- µA(x). 1-0=1.

The same reason why you get (2,1).

The third one (3,0.3) because it is (3,1-0.7)=(3,0.3).

Same reason why you have (4,1) and (7,1).

(6,1-0.8)=(6,0.2).

The member (5,0) is not included because , a singleton whose membership to a fuzzy set is 0, can be excluded .


8. Consider a fuzzy set old as defined below

old={(20,0),(30,0.2),(40,0.4),(50,0.6),(60,0.8),(70,1),(80,1)}. Then the alpha-cut for alpha=0.4 for the set old will be (A){(40,0.3)}

(B){50,60,70,80}

(C){(20,0.1),(30,0.2)}

(D){(20,0),(30,0),(40,1),(50,1),(60,1),(70,1),(80,1)}

Ans:-D

Explanation:-

alpha-cut of a fuzzy set A will contain those elements where the membership function value is equal to or greater than alpha.

Here, alpha is given a value 0.4. Starting from (40,0.4) all the members have membership function equal or greater than 0.4. so, except

(20,0) and (30,0.2) all the menbers are included in the alpha-cut of the fuzzy set. The only option which has 40,50,60,70, and 80 included is option D. It has

(20,0) and (30,0) too. But it is already noted that any singleton where the membership function is 0 can be considered not included. So basically these two members are not part of the alpha-cut of the fuzzy set A. So the correct option is D.